Torque to angles

Started by
3 comments, last by _WeirdCat_ 8 years, 2 months ago

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?

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);

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

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.

ok then ill just inverse rotation matrix and dot3 it with torque vector, no harm done

This topic is closed to new replies.

Advertisement