#### Archived

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

# Getting a direction vector from a point and 3 angles

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

## Recommended Posts

Hi, I can do this on paper during an algebra exam, but do you think I can do it during my own time for my own hobby (in programming that is)? Yeah right. How do I get the direction vector from a 3D point and 3 angles (pitch, yawl, and roll)? It''s so i can translate a point in 3D space using: x'' = x + tx; y'' = y + ty; z'' = z + tz; Thanks, Scott btw: I might have used some wrong terms or something, so please let me know

##### Share on other sites
The three angles together are called Euler angles, and they are one oway of describing a rotation in space. They are not the easiest to work with though, so you may find it easier to convert them to quaternion or matrix form. You can find source for this in varioius places, including probably on this site.

Euler angles, a quaternion or a matrix describe a rotation. To get a direction from this you need to start from an initial direction, perhaps the default ''forward'' direction of your car/spaceship/player. Apply the quaternion or matrix to your initial direction to get the desired final direction.

##### Share on other sites
I just logged on to ask a similar question

To help get you started - translation on the x/z plane:

x (-=)(+=) sin(yRotAngle) * MoveSpeed;
z (-=)(+=) cos(yRotAngle) * MoveSpeed;

The problem I''ve run into is adding the Y component. I''ve worked out this much:

y (+=)(-=) tan(xRotAngle) * MoveSpeed;

In First Person mode, this is all I need and it works fine. However, I want to implement a fly-through mode for my level editor. The problem starts when I rotate the x-axis too much. Then, instead of going forward I wind up going backward. I did a check of the value of the xRotAngle, and if xRotAngle >= 180 && xRotAngle < 360, I negated the resulting tan. Didn''t work. Anyone have any ideas for me?

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
3002226
×