I was pointed out by a friend that in the modified version I should skip the last line. So the coude should look this:
oriMat = quaternion.ToMatrix(self.ori) self.totalTorque = vector.Transform(self.totalTorque, matrix.Inverted(oriMat)) angAcc = vector.Transform(self.totalTorque, matrix.Inverted(self.inertia_local))
And indeed that works. I wrote down on paper all these transforms and this code gives the exact same series of transforms as the original one.
angAcc = torque * inertia^-1 = torque_world * (inertia_local * localToWorld)^-1 = torque_world * localToWorld^-1 * inertia_local^-1
Clearly this gives angAcc in world-space what I need.
The modified new:
angAcc = torque * inertia^-1 = (torque_world * localToWorld^-1) * inertia_local^-1 = torque_world * localToWorld^-1 * inertia_local^-1
This I would expect to give me angAcc in local-space (which further needs to be mul'led by localToWorld to be in world space) but math clearly shows this is the same as the previous formula.
Anyone sees what is wrong with my understanding?