io7m
io7m-jtensors 7.0.0-beta0004
2.3
Quaternions

- 2.3.1. Types
- 2.3.2. Rotations & Handedness
- 2.3.3. Access control

2.3.1
Types
1
The io7m-jtensors package provides quaternions with single-precision (float) elements, and double-precision (double) elements. Each quaternion type is available in mutable or immutable versions. The package unambiguously identifies the quaternion types by using the following naming conventions for the types (given as a simple EBNF grammar):
2.3.1.1. Quaternion type naming

    mutability   = "M" | "I" ;
    size         = "4" ;
    element_type = "F" | "D" ;
    type         = "Quaternion" , mutability , size , element_type ;

2
A comprehensive list of the available quaternion types is as follows:
2.3.1.2. Available quaternion types

- QuaternionM4D
- QuaternionM4F
- QuaternionI4D
- QuaternionI4F

2.3.2
Rotations & Handedness
1
The included quaternion types and functions have consistent semantics and assumptions with regards to rotation and coordinate systems as the Matrix types, and functions are provided to convert between matrices and quaternions.
2.3.3
Access control
1
If a function only needs to read from a value of a quaternion type, then it would be desirable to be able to statically enforce this fact. Therefore, the package provides a set of Readable interfaces that all quaternion types implement. By writing a function that takes a value of a type implementing a Readable interface, the programmer is implicitly stating that this function does not modify the quaternion.
2.3.3.1. Available quaternion Readable types

- QuaternionReadable4FType
- QuaternionReadable4DType

2
Writable interfaces are provided:
2.3.3.2. Available quaternion Writable types

- QuaternionWritable4FType
- QuaternionWritable4DType

3
Interfaces that abstract over mutable quaternions are provided:
2.3.3.3. Available quaternion types

- Quaternion4FType
- Quaternion4DType