- Home /
Rotational energy formula
Need to calculate a kinetic rotational energy of game object (for a physics educational demonstration). As known, kinetic calculation formula is:
The question concern only realization of rotational part: We have rigid body angular velocity (w in formula), inertia tensor (Jc). But also we have quaternion of inertia tensor rotation. So the question: is the code to calculate rotational kinetic energy correct?
float rigidbodyEnergy(Vector3 linVel, Vector3 angVel, Rigidbody rb)
{
Quaternion itr = rb.inertiaTensorRotation;
return Vector3.Dot(angVel,
itr * Vector3.Scale(rb.inertiaTensor, Quaternion.Inverse(itr) * angVel))/2f
+linVel.sqrMagnitude*rb.mass/2f;
}
energy1.jpg
(5.1 kB)
Comment