114.1 Quaternion Tools By Doug Sweetser 

Quaternion Algebra Toolset:

Here is a compilation of basic algebra for quaternions. It should look very similar to complex algebra, since it contains three sets of complex numbers, t + i x, t + j y and t + k z. To strengthen the link, and keep things looking simpler, all quaternions have been written as a pair of a scalar t and a 3-vector V, (t, V). All these relations have been tested in a Java quaternion calculator I have built that is under development.

Simple Algebra..............................................Parts

sum(q, q') = (t + t', V + V')...................scalar(q) = (q + q*)/2 = (t, 0)

dif(q, q') = (t - t', V - V')......................vector(q) = (q - q*)/2 = (0, V)

conj(q) = q* = (t, -V)........................|q| = (q* q)^.5 = ((t^2 + V.V)^.5, 0)

inv(q) = q*/(q* q) = (t, -V) / |q|^2..............norm(q) = (t^2 + V.V, 0)

adj(q) = q* q* q = (t, -V).......................|q|^2det(q) = ((t^2 + V.V)^2, 0)

Multiplication
Grassman q q'

qxeven(q, q') + qxodd(q, q') = qx(q, q')
(t t' - V.V', tV' + Vt') (0, VxV') (t t' - V.V', tV' + Vt' + VxV')

Euclidean q* q'

qcxeven(q, q') + qcxodd(q, q') = qcx(q, q')
(t t' + V.V', 0) (0, tV' - Vt' - VxV') (t t' + V.V', tV' - Vt' - VxV')

Trig

sin(q) = (sin(t) cosh(|V|),

  • cos(t) sinh(|V|) V/|V|),
  • cos(q) = (cos(t) cosh(|V|),

  • - sin(t) sinh(|V|) V/|V|)
  • tan(q) = sin() / cos()

    asin(q) = -V/|V| asinh(q V/|V|)

    acos(q) = -V/|V| acosh(q)

    atan(q) = -V/|V| atanh(q V/|V|)

    sinh(q) = (sinh(t) cos(|V|),

  • cosh(t) sin(|V|) V/|V|)
  • cosh(q) = (cosh(t) cos(|V|),

  • sinh(t) sin(|V|) V/|V|)
  • tanh(q) = sinh(q) / cosh(q)

    asinh(q) = ln(q + (q^2 + 1)^.5)

    acosh(q) = ln(q +/- (q^2 - 1)^.5)

    atanh(q) = .5 ln((1 + q)/(1 - q))

    Powers

    exp(q) = (exp(t) cos(|V|),

  • exp(t) sin(|V|) V/|V|)
  • q ^ q' = exp(ln(q) x q')

    Logs

    ln(q) = (0.5 ln(t^2 + V.V),

  • atan2(|V|, t) V/|V|)
  • log(q) = ln(q)/ln(10)

    Multiplying using exponetials

    q q' =

  • {q,q'} + |[q, q']| exp(pi [q, q']/2 |[q,q']|)
  • where

  • {q,q'} = (qq' + q'* q*)/2 [q,q'] = (qq' - q'* q*)/2
  • q* q' =

  • {q,q'} + |[q, q']| exp(pi [q, q']/2 |[q,q']|)
  • where

  • {q,q'} = (q* q' + q'* q)/2 [q,q'] = (q* q' - q'* q)/2
  • Andrew Millard suggested the commutators for the Grassman product.

    Impossible Correspondence Index

    © Copyright. Robert Grace. 2001