Scad_ml.QuaternionProvides functions for the creation of and operations between quaternions. These can be used to create composable and interpolatable rotations to be applied to vectors (e.g. Vec3.t) directly, and Scad.t through MultMatrix.t.
val id : tThe identity quaternion: (0., 0., 0., 1.)
make ax angle
Create a quaternion representing a rotation of angle (in radians) around the vector ax.
add_scalar t s
Add s to the magnitude of t, leaving the imaginary parts unchanged.
sub_scalar t s
Subtract s from the magnitude of t, leaving the imaginary parts unchanged.
scalar_sub_quat t s
Negate the imaginary parts of t, and subtract the magnitude from s to obtain the new magnitude.
val norm : t -> floatnorm t
Calculate the vector norm (a.k.a. magnitude) of t.
normalize t
Normalize t to a quaternion for which the magnitude is equal to 1. e.g. norm (normalize t) = 1.
conj t
Take the conjugate of the quaternion t, negating the imaginary parts (x, y, and z) of t, leaving the magnitude unchanged.
distance a b
Calculate the magnitude of the difference (Hadamard subtraction) between a and b.
val of_rotmatrix : RotMatrix.t -> tval to_multmatrix : t -> MultMatrix.tval to_string : t -> stringval get_x : t -> floatval get_y : t -> floatval get_z : t -> floatval get_w : t -> floatslerp a b step
Spherical linear interpotation. Adapted from pyquaternion.
rotate_vec3_about_pt t p v
Translates v along the vector p, rotating the resulting vector with the quaternion t, and finally, moving back along the vector p. Functionally, rotating about the point in space arrived at by the initial translation along the vector p.