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 , but not . One reason for that is that the order in swizzling is xyzw.
However, most Julia packages use order. This is for consistency with Base.Complex's order.
Packages for Quaternions
Quaternions.jl
Quaternions.jl is the most popular Julia package for quaternions.This package implements
Quaternions.Quaternionwhich is much similar toBase.Complex.This package focus on some basic operations for quaternions. Most implemented methods are added to
Basefunctions.Other operations such as rotations are not implemented in this package. Use Rotations.jl instead.
The arguments for
Quaternions.Quaternionis ordered in .
Historically, this package was not actively maintained before 2022.
Quaternionic.jl
Quaternionic.jl is another Julia package for quaternions.This package exports
AbstractQuaternionas well as three concrete subtypes:Quaternionfor arbitrary quaternions,Rotorfor quaternions with unit magnitude, andQuatVecfor 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
Tof its components, as inQuaternionic.Quaternion{T}, but does not requireT <: Real. As a result, this package can handle biquaternions for example.This package exports
imx,imy, andimz(similar toBase.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 particularChainRulesandForwardDiffare 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
slerpQuadratic interpolation, or
squadConversion to and from angular velocity as a function of time
Conversion to the "minimal-rotation" frame
The arguments for
Quaternionic.Quaternionis ordered in .
Packages that define their own Quaternions
Makie.jl
Makie.jl has its ownQuaternion type, but this should be replaced with Quaternions.Quaternion. Please check comment in Makie.jl/src/utilities/quaternions.jl. Note that Makie.Quaternion uses order. ReferenceFrameRotations.jl
ReferenceFrameRotations.jl also has its ownQuaternion type. There was an issue#25 to be compatible with Quaternions.jl. Grassmann.jl
Grassmann.jl does not implementQuaternion as a struct, but quaternions are realized as an alias Grassmann.Quaternion (alias for Spinor{V, T, 4} where {V, T}). Related discourse posts
Last modified: January 30, 2024. Built with Franklin.jl