package gg

  1. Overview
  2. Docs
type t = quat

The type for quaternions.

Constructors, accessors and constants

val v : float -> float -> float -> float -> quat

v x y z w is the quaternion xi+ yj + zk + w.

val zero : quat

zero is the zero quaternion.

val id : quat

id is the identity quaternion 1.

Functions

val mul : quat -> quat -> quat

mul q r is the quaternion multiplication q * r.

val conj : quat -> quat

conj q is the quaternion conjugate q*.

val unit : quat -> quat

unit q is the unit vector q/|q| (same as V4.unit).

val inv : quat -> quat

inv q is the quaternion inverse q-1.

val slerp : quat -> quat -> float -> quat

slerp q r t is the spherical linear interpolation between q and r at t. Non commutative, torque minimal and constant velocity.

val squad : quat -> quat -> quat -> quat -> float -> quat

squad q cq cr r t is the spherical cubic interpolation between q and r at t. cq and cr indicate the tangent orientations at q and r.

val nlerp : quat -> quat -> float -> quat

nlerp q r t is the normalized linear interpolation between q and r at t. Commutative, torque minimal and inconstant velocity.

3D space transformations

val of_m3 : m3 -> quat

of_m3 m is the unit quaternion for the rotation in m.

val of_m4 : m4 -> quat

of_m4 m is the unit quaternion for the rotation in the 3x3 top left matrix in m.

val rot3_map : v3 -> v3 -> quat

Unit quaternion for the rotation, see M3.rot3_map.

val rot3_axis : v3 -> float -> quat

Unit quaternion for the rotation, see M3.rot3_axis.

val rot3_zyx : v3 -> quat

Unit quaternion for the rotation, see M3.rot3_zyx.

val to_rot3_axis : quat -> v3 * float

to_rot3_axis q is the rotation axis and angle of the unit quaternion q.

val to_rot3_zyx : quat -> v3

to_rot_zyx q is the x, y, z axis angles of the unit quaternion q.

val apply3 : quat -> v3 -> v3

apply3 q v applies the 3D rotation of the unit quaternion q to the vector (or point) v.

val apply4 : quat -> v4 -> v4

apply4 q v apply the 3D rotation of the unit quaternion q to the homogenous vector (or point) v.

OCaml

Innovation. Community. Security.