URL: https://graphicscomputing.fr/cgp/reference/quaternion/
Description: Quaternion, used to represent rotations.

# quaternion

Quaternion, used to represent rotations.

Fields:

- `T x` - First coordinate of the vector.
- `T y` - Second coordinate of the vector.
- `T z` - Third coordinate of the vector.
- `T w` - Fourth coordinate of the vector.

Functions taking it:

- `void check_index_bounds(INDEX_TYPE index, numarray_stack<T,4> const& data)` - Raises an error if the index is outside [0, 3]; no-op when CGP_NO_DEBUG is defined.
- `T const& get(numarray_stack<T,4> const& data)` - Component idx with the index checked at compile time (static_assert).
- `std::string type_str(numarray_stack<T,4> const&)` - Type name as a string, e.g. "numarray_stack4<int>".
- `std::string type_str(vec4 const&)` - Type name as a string: "vec4".
- `mat4 tensor_product(vec4 const& a, vec4 const& b)` - Outer product a * transpose(b), as a 4x4 matrix.
- `std::string type_str(quaternion const&)` - Type name "quaternion".
- `quaternion conjugate(quaternion const& q)` - Quaternion conjugate (= inverse for a unit quaternion).
- `quaternion inverse(quaternion const& q)` - Quaternion inverse.
- `quaternion normalize(quaternion const& q)` - Unit quaternion in the same direction.
- `void opengl_uniform(opengl_shader_structure const& shader, std::string const& name, vec4 const& value, bool expected = true)` - Send a vec4 uniform to the shader; warns if the uniform is not found and expected is true.

Operators:

- `vec4 operator*(affine const& T, vec4 const& p)` - Apply the affine transform to a homogeneous vector, the translation being weighted by w: a direction (w=0) is not translated.
- `vec4 operator*(affine_rt const& T, vec4 const& p)` - Apply the rigid transform to a homogeneous vector, the translation being weighted by w.
- `vec4 operator*(affine_rts const& T, vec4 const& p)` - Apply the transform to a homogeneous vector, the translation being weighted by w.
- `quaternion& operator*=(quaternion& a, quaternion const& b)` - In-place quaternion (Hamilton) product a = a * b.
- `quaternion operator*(quaternion const& a, quaternion const& b)` - Quaternion (Hamilton) product, with the scalar part stored in w.
- `quaternion operator*(quaternion const& a, float b)` - Quaternion with each component multiplied by a scalar.
- `quaternion operator*(float a, quaternion const& b)` - Quaternion with each component multiplied by a scalar.
- `quaternion& operator/=(quaternion& a, quaternion const& b)` - In-place quaternion division a = a * inverse(b).
- `quaternion operator/(quaternion const& a, quaternion const& b)` - Quaternion division a * inverse(b).
- `quaternion operator/(quaternion const& a, float b)` - Quaternion with each component divided by a scalar.
- `quaternion operator/(float a, quaternion const& b)` - Scalar times the inverse quaternion, a * inverse(b).
- `quaternion& operator+=(quaternion& a, quaternion const& b)` - In-place component-wise sum of two quaternions.
- `quaternion operator+(quaternion const& a, quaternion const& b)` - Component-wise sum of two quaternions.
- `quaternion& operator-=(quaternion& a, quaternion const& b)` - In-place component-wise difference of two quaternions.
- `quaternion operator-(quaternion const& a, quaternion const& b)` - Component-wise difference of two quaternions.
- `std::istream& operator>>(std::istream& stream, quaternion& data)` - Read the four components x y z w of a quaternion from a stream.
- `vec4 operator*(rotation_transform const& r, vec4 const& p)` - Homogeneous vector whose xyz part is rotated, w being kept.
