How do I apply an angular velocity vector[3] to a unit quaternion orientation? I have an angular velocity vector[3] in three dimensions and a unit quaternion (magnitude of 1) representing an orientation in three dimensions.
I need to apply the angular velocity to the quaternion orientation, such that the rotation is correct in a Newtonian universe.
I'm sure it was in the books somewhere, but now I can't find it.
Thanks.
Alright, in reply to help; would this be the equations?
Where:
C is q-1 (well, the conjugate, but my books tell me a unit quaterinion conjugate is the same as the negate)
b is the angular velocity, already scaled by time.
a is q and the quaternion to rotate.
So: qbq-1, or abc for quaternion rotation. It's rotating, that's fine.
However, it's applying the angular velocity as if it were a rotation from (1,0,0,0).
To explain what I'm seeing: Let's say we apply an angular velocity, pre-multiplied by dt (delta time). It gets multiplied by the conjugate of the current rotation (which, currently, is (1,0,0,0) and the current rotation, to result in the next rotation.
So the next rotation is initially equal to the angular velocity.
Then we multiply the angular velocity, as a quaternion, by the conjugate of the current rotation.
Which is the conjugate of the angular velocity as a quaternion.
So essentially, we end up with a rotation from (1, 0, 0, 0) each time step.
...And now it's swinging back and forth along the Y axis.
I suspect the problem is in how I'm turning angular momentum into angular velocity; should I make a new topic? Not entirely sure of informal etiquette here. Makes sense too, but figured I'd ask.
 A: It's not entirely clear (to me) what you mean by "applying an angular velocity". Angular velocity is an instantaneous property; if you only have a single angular velocity vector, you only have the first derivative of the motion at one point in time, and thus can't say anything about the orientation at other times.
I'll assume that you're assuming the angular velocity to be constant, and that by "applying" it you mean calculating the orientation at later times of a body that has the given initial orientation and undergoes a motion with the given constant angular velocity.
To do this, you need to know a) how to find the unit quaternion corresponding to a rotation vector and b) how to compose two unit quaternions in order get the unit quaternion corresponding to the composition of the corresponding rotations.
For a), let's denote the angular velocity vector by $\vec{\omega}$. Over a time $t$, a motion with this (constant) angular velocity results in a rotation that can be described by the vector $\vec{w}=\vec{\omega}t$, where the direction and magnitude of $\vec{w}$ specify the axis and angle of the rotation, respectively. This rotation corresponds to the unit quaternion
$$q=\left(\cos\frac{|\vec{w}|}{2},\frac{\vec{w}}{|\vec{w}|}\sin\frac{|\vec{w}|}{2}\right)\;.$$
For b), since applying the rotation corresponding to a unit quaternion $q$ to a three-dimensional vector $\vec{v}$ consists in conjugating a quaternion $\nu$ corresponding to $\vec{v}$ by $q$, composing rotations just corresponds to multiplying the corresponding quaternions:
$$q(\vec{v})=q\nu q^{-1}\;,$$
$$q_1(q_2(\vec{v}))=q_1(q_2\nu q_2^{-1})=q_1q_2\nu q_2^{-1} q_1^{-1}=(q_1q_2)(\vec{v})\;.$$
(This is part of what makes quaternions so useful for representing three-dimensional rotations). So now you just multiply $q$ and your initial unit quaternion, say, $q_0$. Since the initial rotation is applied first, the corresponding unit quaternion is on the inside of the nested conjugations, so it has to be the right-hand factor: $q'=qq_0$.
For more on all this, see this Wikipedia article.
