Geometric algebra solution just for fun.
I'll write uv for the geometric product of vectors u and v.
It's commutative for parallel vectors: uv = vu when u ∥ v,
anticommutative for orthogonal vectors: uv = −vu when u ⊥ v,
and associative: (uv)w = u(vw) = uvw.
Furthermore, uu = |u|² (the square of the length).
Let (x, y, z) be the old right-handed basis.
Vectors in the basis are orthogonal, so xy = −yx, yz = −zy, zx = −xz,
and have length 1, so xx = yy = zz = 1.
The quaternion basis (1, i, j, k) corresponds to the multivector basis (1, zy, xz, yx).
You can check that all the quaternion identities work. For example:
- ij = zyxz = −zyzx = zzyx = yx = k,
- k² = yxyx = −yyxx = −xx = −1,
- ijk = k² = −1.
A quaternion in the old basis can be written as s + b⋅zy + c⋅xz + d⋅yx.
A quaternion in the new basis can be written as S + B⋅yz + C⋅xy + D⋅zx. (We've swapped y and z.)
Solving for the new coefficients, we get S=s, B=−b, C=−d and D=−c.
There are two conventions for writing quaternion coefficients: [s, b,c,d]
and [b,c,d, s]
.
[s=0.130526, b=0, c=0, d=0.991445]
transforms to [S=0.130526, B=0, C=-0.991445, D=0]
.
[b=0.130526, c=0, d=0, s=0.991445]
transforms to [B=-0.130526, C=0, D=0, S=0.991445]
.