Jump to content
  • Advertisement
Sign in to follow this  
_WeirdCat_

Torque to angles

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

So when i have a torque, inertia tensor, and inertia tensor matrix calculated how do i convert that to angles about which the body rotate?

Share this post


Link to post
Share on other sites
Advertisement
This depends also on the time duration you want to observe for rotation and the bodies initial velocity.
You need to refine your question, what do you want to achieve?

Whant we can get from your given numbers is the angular acceleration (rate of change of angular velocity):

vec3 angAcc = bodyWorldMatrix.Unrotate (torque); // rotate torque to local body space, because inertia is relative to local space usually
angAcc[0] /= Ixx; // divide component wise by inertia
angAcc[1] /= Iyy;
angAcc[2] /= Izz;
angAcc = bodyWorldMatrix.Rotate (angAcc); // rotate back to world space and we have angular velocity

You then can get the axis and angle of angular acceleration simply by

float angle = angAcc.Length();
vec3 axis = angAcc / angle; // Don't forget to check gainst error epsilon before the divide ;)

Or, if you want to know angular acc about a given dirction e.g. X axis:

float xAngle = vec(1,0,0).Dot(angAcc); Edited by JoeJ

Share this post


Link to post
Share on other sites

Since computing inverse of rotation mat 'can be' a bit expensive i will rotate inertia tensor by rotation mat and divide torque by that to get ang acc, hopefully that will do

Share this post


Link to post
Share on other sites
Good idea but i think it does not work because inertia is a nonuniform scale which can't be rotated without distortion.
Try it out to be sure. (I'm talking about inertia stored as 3 values, not as a 3x3 matrix)

Notice that a vector Unrotate() needs the same operation as a Rotate(), because the inverse of orthonormal orientation is just it's transpose you can hardcode this, e.g.:

Unrotate:
return Vector3(
( ( ( vec.getX() * mat.getCol0().getX() ) + ( vec.getY() * mat.getCol0().getY() ) ) + ( vec.getZ() * mat.getCol0().getZ() ) ),
( ( ( vec.getX() * mat.getCol1().getX() ) + ( vec.getY() * mat.getCol1().getY() ) ) + ( vec.getZ() * mat.getCol1().getZ() ) ),
( ( ( vec.getX() * mat.getCol2().getX() ) + ( vec.getY() * mat.getCol2().getY() ) ) + ( vec.getZ() * mat.getCol2().getZ() ) )
);

Rotate:
return Vector3(
( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ),
( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ),
( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) )
);


But it is possible to store an additional inertia tensor 3x3 matrix in world space.
I don't because it needs space for every body. Edited by JoeJ

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!