问题
I'm trying to implement a small rigid body physics simulation, using DirectX to draw my objects and its Math library to take advantage of SIMD calculation (XMMATRIX and XMVECTOR classes).
My question is about the Inertia Tensor, I know that using its inverse I can calculate the angular acceleration like so:
AngAcc = Inverse(I) * torque
and that inertia tensor, in local space, is constant... so I have store its inverse in my RigidBody class with some other members:
//'W' suffix means 'world space'
//'L' suffix means 'local space'
XMFLOAT3 m_positionW; //rigid body position
XMFLOAT4 m_orientationW; //angular orientation
XMFLOAT3 m_velocityW; //linear velocity
XMFLOAT3 m_rotationW; //angular velocity (rotation)
XMFLOAT3X3 m_inverseInertiaTensorL; //inverse of the body inertia tensor in local space (constant)
XMFLOAT4X4 m_worldTransform; //transform matrix for converting body space into world space
XMFLOAT3X3 m_inverseInertiaTensorW; //inverse of the body inertia tensor in world space (change every frame)
Now, at each frame, I have to calculate the inverse Inertia Tensor in world coordinates... and at this point I'm a little confused...
How can I do that?
- I have to multiply m_inverseInertiaTensorL by m_worldTransform ? If yes how? the first one is a XMFLOAT3X3 while the second is a XMFLOAT4X4...
I have to use the orientation? Somewhere I read something like: "inverseWorldInertiaTensor = rot*inverseBodyInertiaTensor*rot.transpose()" where I think that 'rot' is a matrix like this:
XMMATRIX rotation = XMMatrixRotationQuaternion(orientationW);
I'm very confused... someone can help me?
回答1:
I found that multipling m_inverseInertiaTensorL by m_worldTransform is the right way; only the rotation part of m_worldTransform is needed, so you can multiply m_inverseInertiaTensorL by the 3x3-sub-matrix of m_worldTransform.
来源:https://stackoverflow.com/questions/18290798/calculating-rigid-body-inertia-tensor-world-coordinates