Quaternions are hypercomplex numbers used to represent spatial rotations in three dimensions. This set of routines provides a useful basis for working with quaternions in Octave. A tutorial is in the Octave source, scripts/quaternion/quaternion.ps.
These functions were written by A. S. Hodel, Associate Professor, Auburn University.
@anchor{doc-quaternion}
w = a*i + b*j + c*k + d
from given data.
@anchor{doc-qconj}
q = [w, x, y, z] = w*i + x*j + y*k + z qconj (q) = -w*i -x*j -y*k + z
@anchor{doc-qderiv}
Let Q be a quaternion to transform a vector from a fixed frame to a rotating frame. If the rotating frame is rotating about the [x, y, z] axes at angular rates [wx, wy, wz], then the derivative of Q is given by
Q' = qderivmat (omega) * Q
If the passive convention is used (rotate the frame, not the vector), then
Q' = -qderivmat (omega) * Q
@anchor{doc-qderivmat}
Let Q be a quaternion to transform a vector from a fixed frame to a rotating frame. If the rotating frame is rotating about the [x, y, z] axes at angular rates [wx, wy, wz], then the derivative of Q is given by
Q' = qderivmat (omega) * Q
If the passive convention is used (rotate the frame, not the vector), then
Q' = -qderivmat (omega) * Q.
@anchor{doc-qinv}
q = [w, x, y, z] = w*i + x*j + y*k + z qmult (q, qinv (q)) = 1 = [0 0 0 1]
@anchor{doc-qmult}
[w, x, y, z] = w*i + x*j + y*k + z
identities:
i^2 = j^2 = k^2 = -1 ij = k jk = i ki = j kj = -i ji = -k ik = -j
@anchor{doc-qtrans}
v = q*v/q
.
@anchor{doc-qtransv}
vi = (2*real(q)^2 - 1)*vb + 2*imag(q)*(imag(q)'*vb) + 2*real(q)*cross(imag(q),vb)
Where imag(q) is a column vector of length 3.
@anchor{doc-qtransvmat}
[vv, th] = quaternion (qib)
.
@anchor{doc-qcoordinate_plot}
Go to the first, previous, next, last section, table of contents.