To answer the question simply, given:
P = [0, p1, p2, p3] <-- point vector
R = [w, x, y, z] <-- rotation
R' = [w, -x, -y, -z]
For the example in the question, these are:
P = [0, 1, 0, 0]
R = [0.707, 0.0, 0.707, 0.0]
R' = [0.707, 0.0, -0.707, 0.0]
You can calculate the resulting vector using the Hamilton product H(a, b)
by:
P' = RPR'
P' = H(H(R, P), R')
Performing the calculations:
H(R, P) = [0.0, 0.707, 0.0, -0.707]
P' = H(H(R, P), R') = [0.0, 0.0, 0.0, -1.0 ]
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 of P'
will always be 0
and can therefore be discarded.)
For those unfamiliar with quaternions, it's worth noting that the quaternion R
may be determined using the formula:
a = angle to rotate
[x, y, z] = axis to rotate around (unit vector)
R = [cos(a/2), sin(a/2)*x, sin(a/2)*y, sin(a/2)*z]
See here for further reference.
The space of unit quaternions is isomorphic to $SO(3)$ (the space of possible rotations in 3D space), plus a double cover (which is not important in this context). It's easier to picture a sphere for visualization purposes, though. Now imagine you want to change the quaternion vector (which is a vector from the origin to the surface of the (hyper-)sphere). Since you want to keep the length of the vector the same, you have to move it orthogonally to its direction (for a sphere, this means up/down and left/right, but not in/out of the sphere). Thus, you need a vector whose dot product with the $orientation$ quaternion is zero.
But pure imaginary quaternions are orthogonal to pure real ones, and the real axis represents the identity rotation (no rotation at all). Additionally, if $q_1$ and $q_2$ are quaternions, $u$ is a unit quaternion, and $q_1\cdot q_2=0$, then $(q_1u)\cdot(q_2u)=0$ as well (this is because under the interpretation of quaternions as rotations, they are isometries, so they preserve distance and angles), so $orientation\cdot (q_i\ orientation)=0$, if $q_i$ is any pure-imaginary quaternion.
It's a bit more work that the specific choice $q_i=\frac{\Delta t}2(\omega_x{\bf i}+\omega_y{\bf j}+\omega_z{\bf k})$ gives you the amount and axis of rotation you want in your mapping from quaternions to actual rotations, but accepting that, the sum $orientation+(q_i\ orientation)$ gives you a new vector, which is the same length as the old one (to first order), but pointing in a different direction, which is what you wanted. Since there is a second order term that will tend to increase the distance to the the center (which should be intuitively obvious; imagine moving tangent to a sphere from a point on the surface—you stay near the surface for a while, but as you continue straight, you will drift away from the surface), you presumably want a step after those shown to renormalize the vector back onto the sphere.
The answer I just gave is more a programmer's answer than a mathematician's, since your question seemed quite concrete and grounded in some numerical computation. That said, the math angle here has to do with the isomorphism from the space of unit quaternions to the group $\operatorname{Spin}(3)$, which is the simply connected double cover of $SO(3)$ (as I mentioned. Moreover, the Lie algebra $\mathfrak{so}(3)$ generated by (either of) these groups is exactly the space of skew-symmetric $3\times3$ matrices $[\omega]_\times$ for all possible 3-vectors $\omega$, which is exactly what you are doing with your own angular velocity vector. (Note that $[\omega]_\times$ is the 3D Hodge star, defined here.)
Best Answer
So in the complex picture, rotations and dilations of the plane are acheived just by multiplying with a complex number.
I see here you are transferring that idea, but as you said, you get stuck if your three axes are $1,i,j$, because $ij=k$, which is a fourth axis perpendicular to the first two. If you're willing to imagine a four-dimensional space, then you have a similar picture to the complex numbers: multiplication by $i$ would permute the set $\{\pm 1, \pm i,\pm j,\pm k\}$ just as multiplying by $i$ permutes $\{\pm 1, \pm i\}$.
There is a more useful way to view quaternions as rotations in 3-space, though. Imagine $i,j,k$ acting as orthogonal unit vectors, as in physics. Linear combinations of these model every point in that 3-space as a "pure" quaternion $v$ with no real part. Now given another nonzero quaternion $q$, conjugating $v$ to become $qvq^{-1}$ produces a tranformation of the 3 space! When $q$ is a unit-length quaternion, this transformation is actually a rotation.
Try it out with $q=i$ and see what happens to the $i,j,k$ axes! If you feel like skipping $j$ and $k$, you can try $\sqrt{2}/2 +i\sqrt{2}/2$ (whose inverse is, naturally, $\sqrt{2}/2 -i\sqrt{2}/2$.)
This is not useful in the complex numbers because $aba^{-1}=b$ by commutativity, so no change occurs. However, the noncommutativity of the quaternions allows interesting stuff to happen :)
One thing to keep in mind about this conjugation action modeling rotations is that many rotations are produced by a pair of unit-length quaternions (and not just one unit-length quaternion). All that means is that there is a slight redundancy in the way unit-length quaternions model rotations.
EDIT: I just wanted to add a little more trying to justify why "just one more" doesn't seem to work. In analogy with the complex numbers, you want to get $1,i,j$ such that the produce of any two lands in $\{\pm1, \pm i \pm j\}$. As you noted, we have to figure out where $ij$ goes. But if $ij=\pm i$, that implies that $-j=\pm -1$, and then $j$ is not orthogonal to 1. Similarly, $ij\neq \pm j$. The only thing left is if $ij=\pm 1$, but then $-j=\pm i$, and $j$ is not perpendicular to $i$.