Quaternions

Quaternions are best known for their suitability as representations of 3D rotational orientation. They can also be viewed as an extension of complex numbers.

Many softwares such as SciPy and ROS, they treat the order of a quaternion as xi+yj+zk+wxi+yj+zk+w, but not w+xi+yj+zkw+xi+yj+zk. One reason for that is that the order in swizzling is xyzw.

However, most Julia packages use w+xi+yj+zkw+xi+yj+zk order. This is for consistency with Base.Complex's x+yix+yi order.

Packages for Quaternions

Quaternions.jl

GitHub Repo stars deps Quaternions Downloads
Stable Dev GitHub last commit (branch) version Coverage
Quaternions.jl is the most popular Julia package for quaternions.

  • This package implements Quaternions.Quaternion which is much similar to Base.Complex.

  • This package focus on some basic operations for quaternions. Most implemented methods are added to Base functions.

  • Other operations such as rotations are not implemented in this package. Use Rotations.jl instead.

  • The arguments for Quaternions.Quaternion is ordered in w+xi+yj+zkw+xi+yj+zk.

Historically, this package was not actively maintained before 2022.

Quaternionic.jl

GitHub Repo stars deps Quaternionic Downloads
Stable Dev GitHub last commit (branch) version Coverage
Quaternionic.jl is another Julia package for quaternions.

  • This package exports AbstractQuaternion as well as three concrete subtypes: Quaternion for arbitrary quaternions, Rotor for quaternions with unit magnitude, and QuatVec for quaternions with zero scalar part (corresponding to ordinary three-vectors). These allows specializations for faster and/or more precise results in those special cases.

  • Each of the types parametrizes the type T of its components, as inQuaternionic.Quaternion{T}, but does not require T <: Real. As a result, this package can handle biquaternions for example.

  • This package exports imx, imy, and imz (similar to Base.im), and their unicode counterparts 𝐢, 𝐣, and 𝐤.

  • Special care is taken to ensure that functions such as log, exp, sqrt, etc., are accurate and smooth near singularities and branch cuts, and to ensure that they are differentiable at those points. In particular ChainRules and ForwardDiff are explicitly supported.

  • Methods are directly included to permit transformation to and from various representations of rotations, such as Euler angles, spherical coordinates, axis-angle, and rotation-matrix representations.

  • Several functions are included to find the optimal rotation to align two sets of points, or the optimal rotor to align two sets of rotors, and to measure distances between quaternions or rotors.

  • This package also enables various ways of dealing with quaternion-valued functions of time, including

    • Linear interpolation, or slerp

    • Quadratic interpolation, or squad

    • Conversion to and from angular velocity as a function of time

    • Conversion to the "minimal-rotation" frame

  • The arguments for Quaternionic.Quaternion is ordered in w+xi+yj+zkw+xi+yj+zk.

Packages that define their own Quaternions

Makie.jl

GitHub Repo stars deps Makie Downloads
Stable Dev GitHub last commit (branch) version
Makie.jl has its own Quaternion type, but this should be replaced with Quaternions.Quaternion. Please check comment in Makie.jl/src/utilities/quaternions.jl. Note that Makie.Quaternion uses xi+yj+zk+wxi+yj+zk+w order.

ReferenceFrameRotations.jl

GitHub Repo stars deps ReferenceFrameRotations Downloads
Stable Dev GitHub last commit (branch) version Coverage
ReferenceFrameRotations.jl also has its own Quaternion type. There was an issue#25 to be compatible with Quaternions.jl.

Grassmann.jl

GitHub Repo stars deps Grassmann Downloads
Stable Dev GitHub last commit (branch) version Coverage
Grassmann.jl does not implement Quaternion as a struct, but quaternions are realized as an alias Grassmann.Quaternion (alias for Spinor{V, T, 4} where {V, T}).

This website is a community effort covering a lot of ever-changing information. It will therefore never be complete or without error. If you see something wrong, or have something to contribute, please see the "Contributing" section in the github repository.

Last modified: January 30, 2024. Built with Franklin.jl