#### Archived

This topic is now archived and is closed to further replies.

# Vectors

This topic is 6607 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, How do you calculate the direction of a vector in 3 dimensions? ECKILLER

##### Share on other sites
Direction? I'm not sure what exactly you mean by that, if you mean the x, y and z components of the vector then you do it like this. If you have a vector defined by two angles and a magnitude then:

x = v.cos(phi).sin(theta)
y = v.sin(phi)
z = v.cos(phi).cos(theta)

Where phi is the angle between the x/z plane and the vector, theta is the angle between the vector and the x-axis and v is the magnitude of the vector.

These calculations assume the +z-axis runs towards the center of the screen, the +y-axis runs up the screen and the +x-axis runs to the right of the screen.

If you mean how do you calculate the magnitude of the vector and the angles it's orientated at. If you have the vector defined as x,y,z. Then do this:

v = sqrt(x.x+y.y+z.z)
theta = tan-1(z/x)
phi = sin-1(y/v)

Using the same situation as above.

I think that's right. Hope it helps.

Edited by - Chris F on June 17, 2000 12:34:39 AM

1. 1
2. 2
3. 3
Rutin
24
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002233
×