/// <summary>
/// Creates an inverse translation Matrix
/// </summary>
/// <param name="translation"></param>
/// <param name="scale"></param>
/// <param name="orientation"></param>
/// <returns></returns>
public static Matrix4 ComposeInverse(Vector3 translation, Vector3 scale, Quaternion orientation)
{
// Invert the parameters
Vector3 invTranslate = -translation;
Vector3 invScale = new Vector3(1f / scale.x, 1f / scale.y, 1f / scale.z);
Quaternion invRot = orientation.Inverse();
// Because we're inverting, order is translation, rotation, scale
// So make translation relative to scale & rotation
invTranslate *= invScale; // scale
invTranslate = invRot * invTranslate; // rotate
// Next, make a 3x3 rotation matrix and apply inverse scale
Matrix3 rot3x3, scale3x3;
rot3x3 = invRot.ToRotationMatrix();
scale3x3 = Matrix3.Zero;
scale3x3.m00 = invScale.x;
scale3x3.m11 = invScale.y;
scale3x3.m22 = invScale.z;
// Set up final matrix with scale, rotation and translation
Matrix4 result = scale3x3 * rot3x3;
result.Translation = invTranslate;
return(result);
}