Next: System Utilities, Previous: Audio Processing, Up: Top

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.

— Function File: [`a`, `b`, `c`, `d`] = **quaternion** (`w`)

— Function File: [`vv`, `theta`] = **quaternion** (`w`)

— Function File:`w` = **quaternion** (`a, b, c, d`)

— Function File:`w` = **quaternion** (`vv, theta`)

— Function File: [

— Function File:

— Function File:

Construct or extract a quaternion

w = a*i + b*j + c*k + dfrom given data.

— Function File: **qconj** (`q`)

Conjugate of a quaternion.

q = [w, x, y, z] = w*i + x*j + y*k + z qconj (q) = -w*i -x*j -y*k + z

— Function File: **qderiv** (`omega`)

Derivative of a quaternion.

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) * QIf the passive convention is used (rotate the frame, not the vector), then

Q' = -qderivmat (omega) * Q

— Function File: **qderivmat** (`omega`)

Derivative of a quaternion.

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) * QIf the passive convention is used (rotate the frame, not the vector), then

Q' = -qderivmat (omega) * Q.

— Function File: **qinv** (`q`)

Return the inverse of a quaternion.

q = [w, x, y, z] = w*i + x*j + y*k + z qmult (q, qinv (q)) = 1 = [0 0 0 1]

— Function File: **qmult** (`a, b`)

Multiply two quaternions.

[w, x, y, z] = w*i + x*j + y*k + zidentities:

i^2 = j^2 = k^2 = -1 ij = k jk = i ki = j kj = -i ji = -k ik = -j

— Function File: **qtrans** (`v, q`)

Transform the unit quaternion

vby the unit quaternionq. Returnsv`=`

q`*`

v`/`

q.

— Function File: **qtransv** (`v, q`)

Transform the 3-D vector

vby the unit quaternionq. Return a column vector.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.

— Function File: **qtransvmat** (`qib`)

Construct a 3x3 transformation matrix from quaternion

qibthat is equivalent to rotation of th radians about axisvv, where`[`

vv`,`

th`] = quaternion (`

qib`)`

.

— Function File: **qcoordinate_plot** (`qf, qb, qv`)

Plot in the current figure a set of coordinate axes as viewed from the orientation specified by quaternion

qv. Inertial axes are also plotted:

qf- Quaternion from reference (x,y,z) to inertial.
qb- Quaternion from reference to body.
qv- Quaternion from reference to view angle.