public static Vector3d CalculateCenterOfMass( Vector3d[] vertices, TriangleMesh[] triangleMeshes, double mass) { var inertiaTensor = new InertiaTensorEngine( vertices, triangleMeshes, mass, false); return(inertiaTensor.Execute().CenterOfMass); }
public static InertiaTensorOutput GetInertiaTensor( Vector3d[] vertexPosition, TriangleMesh[] triangleMeshes, Vector3d position, double mass) { var inertiaTensor = new InertiaTensorEngine( vertexPosition, triangleMeshes, mass, true); var inertiaTensorRes = inertiaTensor.Execute(); Vector3d r = inertiaTensorRes.CenterOfMass - position; Matrix3x3 baseTensors = inertiaTensorRes.InertiaTensor + (Matrix3x3.IdentityMatrix() * r.Dot(r) - Matrix3x3.OuterProduct(r, r)) * mass; return(new InertiaTensorOutput(baseTensors, inertiaTensorRes.CenterOfMass, inertiaTensorRes.DensityMass)); }