public static MyMatrix3 Transpose(MyMatrix3 matrix) { MyMatrix3 retVal = matrix.Clone(); retVal.Transpose(); return(retVal); }
private void ApplyTorque(double elapsedTime) { // Calculate the new angular momentum (current + (torque * time)) MyVector newMomentum = _internalTorque.Clone(); newMomentum.Multiply(elapsedTime); _angularMomentum.Add(newMomentum); // Figure out the inverse of the world frame's inertia tensor // (Rotation * bodyInertialTensorInverse * Transposed Rotation) MyMatrix3 curRotation = base.RotationMatrix.Clone(); MyMatrix3 inverseWorldInertiaTensor = MyMatrix3.Multiply(MyMatrix3.Multiply(curRotation, _inertialTensorBodyInverse), MyMatrix3.Transpose(curRotation)); // Now all that's left is to figure out the new angular velocity _angularVelocity.StoreNewValues(MyMatrix3.Multiply(inverseWorldInertiaTensor, _angularMomentum)); }
/// <summary> /// Every frame, angular velocity is wiped out and recalculated based on angular momentum. So this function actually /// sets angular momentum to produce the velocity passed in. /// </summary> /// <remarks> /// This function is the opposite of the calculation in ApplyTorque /// </remarks> public void SetAngularVelocity(MyVector angularVelocity) { // Figure out the world frame's inertia tensor // (Rotation * bodyInertialTensorInverse * Transposed Rotation) MyMatrix3 curRotation = base.RotationMatrix.Clone(); MyMatrix3 worldInertiaTensor = MyMatrix3.Multiply(MyMatrix3.Multiply(curRotation, _inertialTensorBody), MyMatrix3.Transpose(curRotation)); // Now store the angular momentum required to generate this velocity _angularMomentum.StoreNewValues(MyMatrix3.Multiply(worldInertiaTensor, angularVelocity)); }