Module Quaternions.Q

type ('a, 'b) t
val create : float -> Owl.Mat.mat -> ([ `unit ]_) t

create theta u creates a unit quaternion correponsing to a rotation of angle theta around axis u. Note that u is first normalised so only its direction matters.

val create_real : float -> (_[ `real ]) t
val create_imag : Owl.Mat.mat -> (_[ `imaginary ]) t
val unpack : (__) t -> float * Owl.Mat.mat

Extracts the real (scalar) and imaginary (vector) part of a quaternion

val unpack_flt : (__) t -> float * (float * float * float)
val of_ypr : (float * float * float) -> ([ `unit ]_) t

Create a unit quaternion from the yaw, pitch, and roll angles.

val to_ypr : ([ `unit ]_) t -> float * float * float

Extract (yaw, pitch, roll) from a quaternion; these are the conventions used by J Wilson et al 2018, corresponding to the intrinsic Tait-Bryan angles following the (x'' - y' - z) convention -- cf wikipedia.

val to_vec : (__) t -> Owl.Mat.mat

Packs a quaternion as a 4D vector.

val of_vec : Owl.Mat.mat -> (__) t

Unpacks a 4D vector into a quaternion.

val renormalize : (__) t -> ([ `unit ]_) t

Renormalises a quaternion (so it becomes a unit quaternion)

val dot_prod : (__) t -> (__) t -> float

Quaternion dot product

val sqr_norm : (__) t -> float

Squared norm of a quaternion

val (+) : (_'a) t -> (_'a) t -> (_'a) t

Addition of two quaternions

val (-) : (_'a) t -> (_'a) t -> (_'a) t

Subtraction of two quaternions

val (*) : (__) t -> (__) t -> (__) t

Quaternion product.

val ($*) : float -> (_'a) t -> (_'a) t

Multiplication by a scalar

val (/$) : (_'a) t -> float -> (_'a) t

Division by a scalar

val conj : ('a'b) t -> ('a'b) t
val geodesic_distance : ([ `unit ]_) t -> ([ `unit ]_) t -> float

Geodesic distance on SO(3)

val to3D : ([ `unit ]_) t -> Owl.Mat.mat

place a quaternion inside the 3D ball used to visualise them

val sample : unit -> ([ `unit ]_) t

sample quaternions from a geodesic-uniform distribution on SO(3)