I'm writing a physics engine based on bullet. For a body, the angular velocity is stored as a vec3, which is the normalized axis of rotation scaled by the angle. To add global torque, you simply add to this vec3. However, I want to add torque based on the body's local frame of reference. I was wondering how to approach this.
The approach that I think is viable is.
torquequat = Convert vec3 torque into quaternion.
localtorquequat = Convert localTorque into quaternion.
globaltorquequat = Multiply localTorque by the inverse of the angular position.
combinedtorquequat = torquequat * angularposition.inverse() * localtorquequat.
decompose into axis angle and scale axis by angle.
This feels incredibly involved for adding a local torque. Are there better alternatives?