Jump to content
  • Advertisement
Sign in to follow this  

How do I extract the x angle from a rotation matrix

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

I want to be able to limit my camera rotation so that I can only look up and down, which I believe is related to the X axis. To do this I need to extract the X angle from a rotation matrix. What maths do I need to do to achieve this? I'm trying to do this in VRML if interested. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
A simple way would be to apply the matrix to a unit vector, and use trig n the result to calculate any angles you need. I'm sure there's another "proper" way of doing it.

The best thing would generally be to limit the angles before creating the rotation matrix in the first place. Then you avoid this problem entirely.

Share this post


Link to post
Share on other sites
It's a complete rotation matrix already that's why I need to extract it as I'm suck with it.

I need something like the below but for the x axis, but I don't know the maths to make it. Thanks!

function set_rotation (r)
{
// gets the Y axis
angle = -Math.atan2(r.x * r.z * (1 - Math.cos(r.angle)) +
r.y * Math.sin(r.angle), r.z * r.z * (1 - Math.cos(r.angle)) +
Math.cos(r.angle) );
rotation_changed = angle;
}

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!