2

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?

  1. I have to multiply m_inverseInertiaTensorL by m_worldTransform ? If yes how? the first one is a XMFLOAT3X3 while the second is a XMFLOAT4X4...
  2. 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?

Linus Juhlin
  • 1,175
  • 10
  • 31
Daniel
  • 223
  • 4
  • 9
  • Have you tried: `m_inverseInertiaTensorW = inverse(objectSpaceInertialTensor * m_worldTransform) = m_inverseInertiaTensorL * inverse(m_worldTransform);` – Steve H Aug 17 '13 at 17:37
  • sincerely I don't try it yet, I'm coding this class to build my first simulation guided by some physics engine books and when they ask for the inverse inertia tensor in world coordinates (to be used in the integration step), I really don't have any idea... btw in my code m_worldTransform is a 4x4 matrix whereas m_inverseInertiaTensorL is 3x3, so even in your case this two matrices are not multipliable. :| – Daniel Aug 17 '13 at 18:29

1 Answers1

0

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.

Daniel
  • 223
  • 4
  • 9