Sign in to follow this  

Y-Angle rotation from 3-d vector

This topic is 2319 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

[quote name='Steve_Segreto' timestamp='1312924733' post='4846899']
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?
[/quote]

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:

[size="2"] D3DXVECTOR3 a = v0 - v1;

D3DXVec3Normalize( &a, &a );

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

Share this post


Link to post
Share on other sites

This topic is 2319 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this