Module OgamlMath.Quaternion

Operations on immutable quaternions

This module defines the quaternion type and various operations on it

exception Quaternion_exception of string
Raised when an error occurs (usually a division by zero)
type t = {r : float; i : float; j : float; k : float}
Type of quaternions

Record fields

r : float
i : float
j : float
k : float
val zero : t
Zero quaternion
val one : t
Unit (real) quaternion
val real : float -> t
Returns a real number as a quaternion
val add : t -> t -> t
Adds two quaternions
val times : t -> t -> t
Multiplies two quaternions
val prop : float -> t -> t
Multiplies a quaternion by a scalar
val sub : t -> t -> t
sub q1 q2 returns the quaternion q1 - q2
val rotation : Vector3f.t -> float -> t
Returns the quaternion representing a rotation given by an axis and an angle.
See : OgamlMath.Vector3f
val conj : t -> t
Returns the conjugate of a quaternion
val inverse : t -> t
Returns the inverse of a quaternion. Raises Quaternion_exception if the quaternion is zero
val squared_norm : t -> float
Returns the squared norm of a quaternion
val norm : t -> float
Returns the norm of a quaternion
val normalize : t -> t
Normalizes a quaternion. Raises Quaternion_exception if the quaternion is zero