Zephyr Scientific Library (zscilib)
|
Functions and structs for dealing with unit quaternions and orientation in 3D space. More...
Modules | |
Structs, Enums and Macros | |
Various structs, enums and macros related to quaternions. | |
Initialisation | |
Quaternion initisialisation. | |
Functions | |
Quaternion APIU functionsn. | |
Files | |
file | quaternions.h |
API header file for quaternions in zscilib. | |
Functions and structs for dealing with unit quaternions and orientation in 3D space.
These functions deal largely with unit quaternions. Further work is required to support arbitrary quaternion math.
Quaternions can be thought of in one of three ways:
When working with unit quaternions and orientation or rotation, we'll generally look at quaternions from the second point-of-view, as a scalar and three component vector in 3D space.
With an extra degree of freedom compared to three-value Euler angles, quaternions provide a compact and efficient means of rotating or orienting vectors (x, y, z) in 3D space, similar to how vectors translate points (x, y) in 2D space.
They allow us to avoid a common problem with (otherwise more intuitive!) Euler angles called "gimbal lock".
Gimbal lock occurs when two axes in the Eular angle coincide after a rotation by a multiple of 90 degrees about the third axis, resulting in the loss of a degree of freedom. This leaves us with an unclear value for the logitude of the north or south poles, i.e. "which way is up?!?".
Quaternions also enable not just LINEAR interpolation (lerp) between two points (a and b) in normal space, but spherical linear interpolation (slerp) between two points in a sphere, travelling across the surface of the sphere rather than in a straight line. This enables us to interpolate between arbitrary orientations (x, y, z), not just arbitrary points (x, y).