# Transform inertia tensor

I am trying to translate book: Game Physics Engine Development by Ian Millington to DirectXMath and faced with the code wich transform inertia tensor. Is it right to convert code from book like that: from book:

static inline void _transformInertiaTensor(glm::mat3 &iitWorld, const glm::quat &q, const glm::mat3 &iitBody, const glm::mat4 &rotmat) {
float t4 = rotmat[0][0] * iitBody[0][0] + rotmat[0][1] * iitBody[1][0] + rotmat[0][2] * iitBody[2][0];
float t9 = rotmat[0][0] * iitBody[0][1] + rotmat[0][1] * iitBody[1][1] + rotmat[0][2] * iitBody[2][1];
float t14 = rotmat[0][0] * iitBody[0][2] + rotmat[0][1] * iitBody[1][2] + rotmat[0][2] * iitBody[2][2];
float t28 = rotmat[1][0] * iitBody[0][0] + rotmat[1][1] * iitBody[1][0] + rotmat[1][2] * iitBody[2][0];
float t33 = rotmat[1][0] * iitBody[0][1] + rotmat[1][1] * iitBody[1][1] + rotmat[1][2] * iitBody[2][1];
float t38 = rotmat[1][0] * iitBody[0][2] + rotmat[1][1] * iitBody[1][2] + rotmat[1][2] * iitBody[2][2];
float t52 = rotmat[2][0] * iitBody[0][0] + rotmat[2][1] * iitBody[1][0] + rotmat[2][2] * iitBody[2][0];
float t57 = rotmat[2][0] * iitBody[0][1] + rotmat[2][1] * iitBody[1][1] + rotmat[2][2] * iitBody[2][1];
float t62 = rotmat[2][0] * iitBody[0][2] + rotmat[2][1] * iitBody[1][2] + rotmat[2][2] * iitBody[2][2];

iitWorld[0][0] = t4 * rotmat[0][0] + t9 * rotmat[0][1] + t14 * rotmat[0][2];
iitWorld[0][1] = t4 * rotmat[1][0] + t9 * rotmat[1][1] + t14 * rotmat[1][2];
iitWorld[0][2] = t4 * rotmat[2][0] + t9 * rotmat[2][1] + t14 * rotmat[2][2];
iitWorld[1][0] = t28 * rotmat[0][0] + t33 * rotmat[0][1] + t38 * rotmat[0][2];
iitWorld[1][1] = t28 * rotmat[1][0] + t33 * rotmat[1][1] + t38 * rotmat[1][2];
iitWorld[1][2] = t28 * rotmat[2][0] + t33 * rotmat[2][1] + t38 * rotmat[2][2];
iitWorld[2][0] = t52 * rotmat[0][0] + t57 * rotmat[0][1] + t62 * rotmat[0][2];
iitWorld[2][1] = t52 * rotmat[1][0] + t57 * rotmat[1][1] + t62 * rotmat[1][2];
iitWorld[2][2] = t52 * rotmat[2][0] + t57 * rotmat[2][1] + t62 * rotmat[2][2];
}


to my DirectX code:

XMVECTOR orientation = XMQuaternionNormalize(XMLoadFloat4(&m_orientation));
XMMATRIX orientationMatrix = XMMatrixRotationQuaternion(orientation);