|
-
Mar 20th, 2000, 03:00 AM
#1
Thread Starter
Member
Does anyone have the functions to determine the x,y,z function of a vector based on its angle(s) in degrees? Basically, I'm playing around with objects moving in three dimensions (think 8-ball in space) and cant find the equations to figure out what to add to x,y and z based on the direction of the object.
-
Mar 20th, 2000, 04:27 AM
#2
transcendental analytic
This is a cut from my 3d-engine
The things here are:
position, an userdef-type
.x
.y
.z
alfa is the vertical angle
beta is the horisontal angle
v is the velocity
-------------------------
Sub flightsim() 'Flygsimulatorn förflyttar positionen
position.z = position.z + Sin(-alfa) * Cos(beta) * v
position.Y = position.Y + Cos(-alfa) * Cos(beta) * v
position.X = position.X + Sin(-beta) * v
alfa = alfa + alfav: beta = beta + betav
betav = betav * 0.95 'Friktion vid svängningar
alfav = alfav * 0.95
If alfa > 3.1415 Then alfa = alfa - 3.1415 * 2 '360 grader snurr lösning
If alfa < -3.1415 Then alfa = alfa + 3.1415 * 2
If beta > 3.1415 Then beta = beta - 3.1415 * 2
If beta < -3.1415 Then beta = beta + 3.1415 * 2
End Sub
--------------------------
Don't have time to modify it for your need, but try to get use of the three first lines. Don't bother to translate my swedish comments.
-
Mar 20th, 2000, 06:18 AM
#3
Thread Starter
Member
Thanks, but, it doesn't seem to be doing quite what I expected. How about this, on a 2d plane, the origin in the top left corner, what would one add to the x coordinate of an object if it was moving in a direction described by Q degrees, with Q=0 being the top of the plane, Q=180 being the bottom.
-
Mar 20th, 2000, 07:14 AM
#4
Frenzied Member
OK add R*Cos(Q/57.2958) to y and R* sin(Q/57.2958) to x
VB likes it's angles in radians which is why the 57.2958 is there.
-
Mar 20th, 2000, 08:21 PM
#5
Addicted Member
Your code is commented in Swedish.
Is there a fellow Swede out there?
Myself, I live in Kungsbacka, south of Gothenbourgh.
Pentax
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|