Skip to content

Quaternions package for Mathematica. Focus is on rotations and coordinate frame orientations in 3D.

License

Notifications You must be signed in to change notification settings

hansmilton/QuaternionsHM

Repository files navigation

A package that adds numeric and symbolic quaternion capabilities to Mathematica.
Also some utilities, among them conversions to/from matrix and angle-axis representation.

Scope

Primarily intended for practical and numerical work when rotating coordinate frames in 3D.
But function arguments can also be symbolic. Or a mix of numeric and symbolic.
An exception is the function quatToFromEulerZYX, which requires numeric arguments.

quat is the head of a quaternion expression.
Syntax is quat[q0, q1, q2, q3].
If a normalized quaternion is interpreted as a rotation then q0 is cosine of half the rotation angle,
while {q1, q2, q3} is a vector along the axis of rotation.

Functionality is added to 9 inbuilt functions:

  • NonCommutativeMultiply, quat ** quat
  • Power, quatscalar
  • Conjugate
  • Norm
  • Normalize
  • Exp
  • Log
  • Times, multiplication of quat with scalar
  • Plus, addition of quat with scalar and quat with quat

In addition 6 new functions:

  • quatToFromList
  • quatToFromθV
  • quatToFromMatrix
  • quatRotateVector
  • quatToFromEulerZYX
  • quatFromAlignedMatrix

Matrix representation

Any quaternion can be converted to a 3x3 matrix.
There are two different conventions for representing rotations by matrices:

  • Passive, or coordinate frame oriented
  • Active, or vector oriented

The two conventions are transposes of each other.

This package uses the passive convention.
The matrix rows are the base axes of a rotated frame, as seen from the reference frame.

In contrast, Mathematica's inbuilt function RotationMatrix uses the active convention.
The matrix rows are the base axes of the reference frame, as seen from a rotated frame.

The passive convention matches the result of mapping the function quatRotateVector over
the rows of an identity 3x3 matrix.

About

Quaternions package for Mathematica. Focus is on rotations and coordinate frame orientations in 3D.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published