Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Angular and Directional Vector

Author
Message
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 18th Jul 2003 20:00
I am a math idiots. I was just wondering can we convert a 3-D angular vector to a directional vector?

For example, in 2-D

An angular vector with the magnitude of m and pointing angle theta can be converted to direction vector as:

vx = m*cos(theta)
vy = m*sin(theta)

To convert it back,

m = sqrt(vx*vx + vy*vy)
theta = atanfull(vy, vx)


Can we perform the simillar vector manipulation in 3-D space?
Thanks!
Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 18th Jul 2003 20:23
yeah... you just have to remember what attribute works to which.

vx = m*cos(theta)
vy = m*sin(theta)
vz = m*cos(theta)

m = sqrt(vx*vx + vy*vy + vz*vz) `// dotproduct3
theta = atanfull(vy, vx)
theta = atanfull(theta,acos(vz))

i think thats right, might not be though ... i'll look it all up and get back to ya

Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 19th Jul 2003 07:19
Sorry, but what theta should I used? AngleX, AngleY or AngleZ?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
keeblerElf
23
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United States
Posted: 19th Jul 2003 07:40
m = sqrt(vx*vx + vy*vy + vz*vz) is no the dot product of m. |m|=sqrt(vx*vx+vy*vy+vz*vz). the dot product of a vector is a relationship between two vectors. The dot product of perpindicular vectors is 0 and the farther the vectors are away from being perpindicular the larger the dot product is. The dot product between a vector x1i+y1j+z1k and x2i+y2j+z2k is x1*x2+y1*y2+z1*z2

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 21st Jul 2003 09:02
depends on the angle of attack Bulleye and what you expect to achieve... also depends on the planes your working on at the time.

as for keelber, something for you


keeblerElf
23
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United States
Posted: 21st Jul 2003 23:04


EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 22nd Jul 2003 06:33
@Bulleyes

I don't have a math text handy, but it sounds like you want spherical coords. Or possibly, cylindrical coords. might do. For cylindrical coords you're equations stay the same and z just becomes another variable:

x = m * cos(theta)
y = m * sin(theta)
z = C

Where C is a constant.

Spherical coords are a bit harder. Add another angle for "azimuth" (call it "gamma") - the so there are 3 coords in spherical-space: m, theta, gamma:

x = m * cos(theta) * sin(gamma)
y = m * sin(theta) * sin(gamma)
z = m * cos(gamma)

m is just the length from the origin to the point:

m = sqrt(x*x + y*y + z*z)

theta is still the angle of the line in the x-y plane:

theta = atanfull(y/x)

gamma is the angle relative to the x-y plane, we know z and we know m, so we just use the atan like the x-y case:

gamma = atanfull(z/m)

Give that a shot and see if it works for you...

Ed

keeblerElf
23
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United States
Posted: 22nd Jul 2003 06:40
Yes I used spherical coordinates in a previous post to find the angles between two points in 3-Space...but I don't think what he needs to use spherical coordinates to do what he wants

EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 22nd Jul 2003 06:43
Oh... forgot to mention...

gamma is the angle between the z axis and the point - kinda like holding the rocket launcher straight up for 0 degrees, and then positive 90 degrees would be level with the ground and 180 degrees would be straight down. You probably need to restrain the m,theta,gamma coords and wrap them appropriately or you might get unexpected results from the above equations.

Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 22nd Jul 2003 16:39
Thanks Ed Phillips, I think this is what I am looking for. But it looks funny to me.

z = m * cos(gamma)
gamma = atanfull(z/m)

How do we get z if gamma is unknown? How do get gamma if z is unknown? Get the picture? I am confused. Can anybody fix me?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/

Login to post a reply

Server time is: 2026-07-21 18:37:58
Your offset time is: 2026-07-21 18:37:58