Jump to content
  • Advertisement

Archived

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

BeRSeRKeR[DGT]

Getting angles from vector

This topic is 6627 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 all...sorry for the previous post. I have defined a camera B-Spline path. I know the tangent vector is the velocity and the camera direction in some fraction time. Here is the question: How can I convert the tangent vector (normalized) to angles (pitch, yaw and roll)??. I tried with this but it doesn''t work correctly: void GetAnglesFromVector(D3DVECTOR *v, float *pitch, float *yaw, float *roll) { // pitch // first cuad. if(v->y > 0.0f && v->z > 0.0f) *pitch = acosf(v->z); // second cuad. if(v->y > 0.0f && v->z < 0.0f) *pitch = acosf(v->z); // third cuad. if(v->y < 0.0f && v->z < 0.0f) *pitch = acosf(v->z); // fourth cuad. if(v->y < 0.0f && v->z > 0.0f) *pitch = acosf(v->z); // yaw // first cuad. if(v->x > 0.0f && v->z > 0.0f) *yaw = acosf(v->x); // second cuad. if(v->x < 0.0f && v->z > 0.0f) *yaw = acosf(v->x); // third cuad. if(v->x < 0.0f && v->z < 0.0f) *yaw = acosf(v->x); // fourth cuad. if(v->x > 0.0f && v->z < 0.0f) *yaw = acosf(v->x); // roll // first cuad. if(v->x > 0.0f && v->y > 0.0f) *roll = acosf(v->x); // second cuad. if(v->x < 0.0f && v->y > 0.0f) *roll = acosf(v->x); // third cuad. if(v->x < 0.0f && v->y < 0.0f) *roll = acosf(v->x); // fourth cuad. if(v->x > 0.0f && v->y < 0.0f) *roll = acosf(v->x); } Do you know some better way to make this?? Download the demo here.

Share this post


Link to post
Share on other sites
Advertisement
I have exactly the same problem. Just wanted to post here yesterday when I read your post. I have the three camera vectors (view, up and right) and need the x, y and z rotations. My approach was very similar and I fugured that there MUST exist a fomula for this, so one could do without all the ifs. So if you find any solution, please let me know!

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!