fastmath.quaternion
Categories
Other vars: -I -J -K I J K ONE ZERO acos acosh acot acoth acsc acsch add arg asec asech asin asinh atan atanh complex->quaternion conjugate cos cosh cot coth csc csch delta-eq div exp from-angles from-euler from-rotation-matrix im-i im-j im-k imaginary? inf? log logb mult nan? neg norm normalize pow qsgn quaternion re real? reciprocal rotate rotation-quaternion scalar scale sec sech sin sinh slerp sq sqrt sub tan tanh to-angles to-euler to-rotation-matrix vector zero?
delta-eq
(delta-eq q1 q2)
(delta-eq q1 q2 accuracy)
Compare quaternions with given accuracy (10e-6 by default)
from-angles
(from-angles [x y z])
(from-angles x y z)
Convert Tait–Bryan angles z-y′-x" to quaternion.
from-euler
(from-euler [roll pitch yaw])
(from-euler roll pitch yaw)
Convert Euler ZYX (body 3-2-1) representation to quaternion
Input should be 3d vector contating roll (x), pitch (y) and yaw (z) angles, or individual values.
- roll and yaw should be from
[-pi, pi]
range - pitch should be from
[-pi/2, pi/2]
range
qsgn
(qsgn re im-i im-j im-k)
(qsgn q)
sgn of the quaternion.
Returns 0
for 0+0i+0j+0k
or calls m/sgn
on real part otherwise.
quaternion
(quaternion a b c d)
(quaternion scalar [i j k])
(quaternion a)
Create quaternion from individual values or scalar and vector parts, reprezented as Vec4
.
rotate
(rotate in rotq)
(rotate in angle u)
Rotate 3d in
vector around axis u
, the same as fastmath.vector/axis-rotate
.
rotation-quaternion
(rotation-quaternion angle u)
Create rotation quaternion around vector u and angle alpha
to-euler
(to-euler q)
Convert quaternion to Euler ZYX (body 3-2-1). Quaternion will be normalized before calculations.
Output will contain roll (x), pitch (y) and yaw (z) angles.