Jump to content
  • Advertisement


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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
Share on other sites
Guest Anonymous Poster
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 this post

Link to post
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?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!