> You really only pay the sin/cos costs when translating out to a Mat3x3 at the end.
You don’t need sin/cos for that either.
Here’s a code that does that:
https://github.com/Microsoft/DirectXMath/blob/master/Inc/Dir...
You're right, I was mixing that up with the initial conversion from axis+angle to quaternion.
Until you need to differentiate a quaternion ...
Also, you don't pay the sin/cos costs when converting to a rotation matrix. For angle axis
R = I + (sin x) * S + (1 - cos(x)) * S^2
Where S is the 3x3 skew symmetric matrix.A unit quaternion representing a 3D rotation is sort of like angle axis
q = cos(x/2), sin(x/2) <axis>
But sin(x) = 2*cos(x/2)*sin(x/2)
(1-cos(x) = 2*sin(x/2)*sin(x/2)
Where you pay the cost is in the construction of the quaternion.What is the problem with differentiating a quaternion? E.g. the time derivative of the quaternion w.r.t. a fixed angular velocity is given here: https://fgiesen.wordpress.com/2012/08/24/quaternion-differen... .
I've more often encountered the need to integrate a quaternion, e.g. from inertial measurements or a rigid body physics model, but this is also a textbook lookup away.
* Compact storage compared to matrices
* No gimbal-lock
* Multiplication is cheap (mult + add, very similar to vector operations)
* Interpolation is cheap
You really only pay the sin/cos costs when translating out to a Mat3x3 at the end.