

Quaternions for Quest3D
Quaternion is a data type suitable for defining object orientation and rotations.
Quaternions are easier to work with than matrices and using quaternions helps to avoid gimbal lock problem like in case of Euler angles usage.
Tasks like smooth interpolation between threedimensional rotations and building rotation by vector are fairly simpler to solve with quaternions than with Euler angles or matrices.
Industrial grade inertial trackers and many other orientation sensors can return rotational data in quaternion form, also to avoid gimbal lock problem, and make such values easier to filter by interpolation.
Gimbal lock problem
Currently Quest3D engine does not allow to work with quaternions directly, that’s why we created this package.
“Quaternions for Quest3D” introduces Quaternion data type to Quest3D engine. It also includes several math and conversion functions. All structures and functions made in form of custom Quest3D channels (15 channels in sum).
List of channels in the package
Basic
Quaternion – data type, consists of 4 values
Set Quaternion – set one quaternion to another
Math operations
Add Quaternions – adds two input quaternions and returns sum
Multiply Quaternions – multiplies two input quaternions
Normalize Quaternion – creates normalized quaternion from input quaternion
Conjugate Quaternion – creates conjugated quaternion
Invert Quaternion – creates inverted quaternion (inverted rotation)
Interpolate Quaternions – creates spherical linear interpolation between two quaternions
Conversion operations
Euler to Quaternion – convert three Euler angles (Yaw, Pitch, Roll) to quaternion
Quaternion to Euler – converts quaternion into value vector of Euler angles
Matrix to Quaternion – converts rotational matrix into quaternion
Quaternion to Matrix – converts quaternion into rotational matrix
Vector and Angle to Quaternion – creates quaternion which define rotation on certain angle (in radians) among axis defined by input vector
Quaternion to Vector and Angle – returns axis vector and angle (in radians) which equal to quaternion
Quaternion from two vectors – creates quaternion which define rotation of an object from directional vector A to directional vector B about an axis perpendicular to both
Package includes small examples of how to use channels and two sets of channels compiled for Quest3D 4.3 and Quest3D 4.3.2
Examples, of how some operations could be done using quaternions in Quest3D:
Get rotation quaternion from vector defining axis of rotation and angle in radians
Smooth animation of 3D rotation. Each of the interpolated quaterions can be build differently.
For example, first describes current rotation of object, set by Quest3D’s matrix,
second quaternion describes desired rotation and is build from directional vector.
By interpolating these quaternions you get smooth rotation by all three axes at the same time.
Building rotation matrix from direction vector and object’s forward vector.
This allows you to rotate object to face particular direction.
After calculating needed quaternion you can convert it to a motion matrix or Euler angles for further usage.
You can read more about quaternions here:
Quaternions and spatial rotation on Wikipedia
Quaternion on Wikipedia
And about gimbal lock here:
Gimbal lock on Wikipedia




