# Calculating the rotational acceleration from torque

I’m trying to write a function that takes a Vector3 of torque and calculates the resulting radial acceleration in radians per second per second. I understand that I’ll need to use the `rigidbody.inertiaTensor` and `rigidbody.inertiaTensorRotation` to do this, but I don’t know how they work. Does anybody know how to do this? I would like it to be as accurate as possible. I imagine the signature of the function would be something like the below.

``````public static Vector3 TorqueToAcceleration(Vector3 torque, Vector3 inertialTensor, Quaternion inertialTensorRotation, float rigidbodyMass) {
// Magic happens here
}
``````

Well, I manged to find an answer.

Thanks to help from a friend, the vector seems to contain an object’s resistance to being rotated on each axis, and the quaternion only changes if you have a shape that is not symmetrical.

``````// copied from comment below
public static Vector3 TorqueToAcceleration(Vector3 relativeTorque, Vector3 inertialTensor, Quaternion inertialTensorRotation) {
inertialTensor = inertialTensorRotation * inertialTensor;

float x = Mathf.Abs(relativeTorque.x / inertialTensor.x);
float y = Mathf.Abs(relativeTorque.y / inertialTensor.y);
float z = Mathf.Abs(relativeTorque.z / inertialTensor.z);

return new Vector3(x, y, z);
}
``````

Converted the comment into an answer.

@Nimred
Yes, it seems you’re right ^^. I just copied his comment into the question but hadn’t a closer look at what he has done there. Your code looks right to me.

Vector3.Scale just does a component wise multiplication. So Vector3.Scale(A,B) == new Vector3(A.xB.x, A.yB.y, A.z*B.z); So one vector scales the other component wise.

Unfortunately there’s no component wise reciprocal operator or method. However we could simply write one ^^:

``````public static class Vector3Extension
{
public static Vector3 Reciprocal(this Vector3 v)
{
return new Vector3(1f/v.x, 1f/v.y, 1f/v.z);
}
}
``````

With that helper method I’ve created this method which seems to be correct:

``````public static Vector3 ApplyTensor(Rigidbody rb, Vector3 worldAcceleration)
{
var q = rb.transform.rotation * rb.inertiaTensorRotation;
var qi = Quaternion.Inverse(q);
var acc = qi * worldAcceleration;
acc = Vector3.Scale(acc, rb.inertiaTensor.Reciprocal());
return q * acc;
}
``````

I’ve created a test scene where i added two identical rigidbodies. In FixedUpdate i used

``````    R1.AddTorque(torque,ForceMode.Force);

acc = ApplyTensor(R2, torque);