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.
The simplest way to model 3D rotations with quaternions is to view 3D space as the "imaginary quaternions", that is, use $i,j,k$ vectors like you do in physics to model 3D space. (But no real part.)
Every quaternion with norm 1 produces a rotation of this 3D space by conjugation $x\mapsto qxq^{-1}$, where $q$ is any length 1 quaternion.
The formula is surprisingly simple: pick a vector that points along the axis you want to rotate around, and scale it down to a unit vector, call it $h$. Then, take your angle of rotation $\theta$ and form $q=\cos(\theta/2)+h\sin(\theta/2)$. The result is a unit length quaternion that produces the rotation you wanted. ($\theta$ may be positive or negative, depending on the direction of rotation.)
I'm not sure I understand what you mean by "nullify rotation in the x and y axes", but I was guessing you meant you would like to be able to pick which axis you are rotating around.
Best Answer
To answer the question simply, given:
For the example in the question, these are:
You can calculate the resulting vector using the Hamilton product
H(a, b)
by:Performing the calculations:
Thus, the example above illustrates a rotation of 90 degrees about the y-axis for the point
(1, 0, 0)
. The result is(0, 0, -1)
. (Note that the first element ofP'
will always be0
and can therefore be discarded.)For those unfamiliar with quaternions, it's worth noting that the quaternion
R
may be determined using the formula:See here for further reference.