use of org.joml.Matrix3dc in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsCalculations method calculateFramedMOITensor.
/**
* Generates the rotated moment of inertia tensor with the body; uses the following formula: I'
* = R * I * R-transpose; where I' is the rotated inertia, I is un-rotated interim, and R is the
* rotation matrix.
* Reference: https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_matrix_in_different_reference_frames
*/
private void calculateFramedMOITensor() {
// physCenterOfMass = new Vector(parent.getCenterCoord());
physTickMass = parent.getInertiaData().getGameTickMass();
// Copy the rotation matrix, ignore the translation and scaling parts.
Matrix3dc rotationMatrix = getParent().getShipTransformationManager().getCurrentPhysicsTransform().createRotationMatrix(TransformType.SUBSPACE_TO_GLOBAL);
Matrix3dc inertiaBodyFrame = parent.getInertiaData().getGameMoITensor();
Matrix3d rotationMatrixTranspose = rotationMatrix.transpose(new Matrix3d());
Matrix3d finalInertia = new Matrix3d(rotationMatrix);
finalInertia.mul(inertiaBodyFrame);
finalInertia.mul(rotationMatrixTranspose);
physMOITensor = finalInertia;
physInvMOITensor = physMOITensor.invert(new Matrix3d());
}