#### Archived

This topic is now archived and is closed to further replies.

# Inertia tensor matrix

This topic is 5252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m pretty confused all round with the whole idea of moments of inertia and angular torque, I have been using the matrix for the inertia tensor using a sphere model (using an objects bounding sphere as a guide). Here''s how its calculated (using the Direct 3DX matrix structure):
	float fInertiaTensor = 0.4f*m_Body.fMass*(m_fAttitudeJetRadius)*(m_fAttitudeJetRadius);
m_Body.matIBody._11 = fInertiaTensor;	m_Body.matIBody._12 = 0;				m_Body.matIBody._13 = 0;				m_Body.matIBody._14 = 0;
m_Body.matIBody._21 = 0;				m_Body.matIBody._22 = fInertiaTensor;	m_Body.matIBody._23 = 0;				m_Body.matIBody._24 = 0;
m_Body.matIBody._31 = 0;				m_Body.matIBody._32 = 0;				m_Body.matIBody._33 = fInertiaTensor;	m_Body.matIBody._34 = 0;
m_Body.matIBody._41 = 0;				m_Body.matIBody._42 = 0;				m_Body.matIBody._43 = 0;				m_Body.matIBody._44 = 1;


m_fAttitudeJetRadius is just half the bounding sphere radius (used elswhere for manual rotation, i.e. attitude jets). As you may gather the object I''m trying to simulate is an aeroplane shape, so this inertia tensor is incorrect. The results I get are erratic to say the least, with small collisions causing massive rebounding and spinning. The usage of the above matrix is shown in the following:
//Calculate transpose of rotation matrix.

D3DXMATRIX matRTrans;
D3DXMatrixTranspose(&matRTrans, &b->matR);
//Calculate inverse of moment of inertia.

//(I(inverse) = R * Ibody(inverse) * R(transpose)).

b->matIinv = b->matR * b->matIBodyInv * matRTrans;
//Calculate angular velocity.

//(w = I(inverse) * L)

D3DXVec3TransformCoord(&b->vAngVel, &b->vL, &b->matIinv);

b->matR is simply the rotation matrix of the object. b->matIBodyInv is the precalculated inverse of the above matrix. b->vAngVel is a vector for angular velocity of the object. b->vL is the angular momentum of the object. I am detecting collisions with an OBB tree so there are several bounding boxes that could be used to more accurately calculate the inertia tensor without resorting to using the mesh, but I havn''t a clue how. In fact to be honest I dont really understand what the inertia tensor is for. If anyone could point me to some detailed information on the subject or if anyone can see anything wrong about the above code please let me know. Any help much appreciated. Dave.

##### Share on other sites
First guess at why you''re getting crazy rotations... you''re applying torques to the object at points that do not conform to the geometry described by the inertial tensor.

I''ve found this to be a problem in the past, especially when using a spheroid appropximation for the tensor. Also watch our for tensors calculated from anything roughly "long and thin".

I don''t know of many real-world style references, but there''s plenty of theory and a smattering of source code out there. Googling for "David Baraff physics" is a good starting point.