Jump to content
  • Advertisement
Sign in to follow this  
Steve_Segreto

Y-Angle rotation from 3-d vector

This topic is 2537 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 guys,


Given a 3-d normalized vector (x,y,z) that represents some rotation around the (x,z) axis, how can I figure out the Y-angle (in radians) that this vector represents?

Share this post


Link to post
Share on other sites
Advertisement

Hi guys,


Given a 3-d normalized vector (x,y,z) that represents some rotation around the (x,z) axis, how can I figure out the Y-angle (in radians) that this vector represents?


I dont't know how to do it but this books are pretty good so maybe you can find what you are looking for.

3D_Math_Primer_For_Graphics_And_Game_Development - WordWare
Mathematics_for_Game_Developers - Thompson

Share this post


Link to post
Share on other sites
You can't, because a 3D vector alone is not enough information to represent a rotation (or orientation) - it can represent an axis of rotation, but to represent a rotational offset we need to define a basis for our transform... like another vector, an angle, an orientation, representing the existing orientation *before* we rotated it, from which we may measure a difference.
It can be done using trigonometry, for example using another vector... if I remember correctly its 2 * acos (theta) radians, where theta = the dot product of two vectors. That will work for 3D, or any 2D component axis (say, the XZ plane for precious Y rotation value). You simply perform a 2D dotproduct instead of a 3D one.

Share this post


Link to post
Share on other sites
Thanks guys!

I figured it out using a second vector (v1) and arc tangent like this:

D3DXVECTOR3 a = v0 - v1;

D3DXVec3Normalize( &a, &a );

[color="#0000ff"][color="#0000ff"]
[color="#0000ff"]
return ([color="#0000ff"][color="#0000ff"]float)(atan2f(a.x, a.z);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!