fastmath.quaternion

-I

-J

-K

acos

(acos q)

acosh

(acosh q)

acot

(acot q)

acoth

(acoth q)

acsc

(acsc q)

acsch

(acsch q)

add

(add q1 q2)

Sum of two quaternions

arg

(arg quaternion)

Argument of quaternion, atan2(|vector(q)|, re(q))

asec

(asec q)

asech

(asech q)

asin

(asin q)

asinh

(asinh q)

atan

(atan q)

atanh

(atanh q)

complex->quaternion

(complex->quaternion z)

Create quaternion from complex number

conjugate

(conjugate quaternion)

Returns conjugate of quaternion

cos

(cos q)

cosh

(cosh q)

cot

(cot q)

coth

(coth q)

csc

(csc q)

csch

(csch q)

delta-eq

(delta-eq q1 q2)(delta-eq q1 q2 accuracy)

Compare quaternions with given accuracy (10e-6 by default)

div

(div q1 q2)

Divide two quaternions

exp

(exp q)

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

from-rotation-matrix

(from-rotation-matrix m)

Convert rotation 3x3 matrix to a quaternion

I

im-i

(im-i quaternion)

Return i imaginary part

im-j

(im-j quaternion)

Return j imaginary part

im-k

(im-k quaternion)

Return k imaginary part

imaginary?

(imaginary? quaternion)

Is q is a pure imaginary number?

inf?

(inf? quaternion)

Is infinitive?

J

K

log

(log q)

logb

(logb quaternion b)

log with base b

mult

(mult q1 q2)

Multiply two quaternions.

nan?

(nan? quaternion)

Is NaN?

neg

(neg quaternion)

Negation of quaternion.

norm

(norm quaternion)

Norm of the quaternion, length of the vector

normalize

(normalize quaternion)

Normalize quaternion

ONE

pow

(pow q p)

Quaternion power

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.

re

(re quaternion)

Returns scalar part of quaternion

real?

(real? quaternion)

Is q is a real number?

reciprocal

(reciprocal quaternion)

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

scalar

(scalar quaternion)

Returns scalar part of quaternion, double

scale

(scale quaternion scale)

Scale the quaternion

sec

(sec q)

sech

(sech q)

sin

(sin q)

sinh

(sinh q)

slerp

(slerp q1 q2 t)

Interpolate quaternions

sq

(sq quaternion)

Square of quaternion.

sqrt

(sqrt q)

sub

(sub q1 q2)

Difference of two quaternions

tan

(tan q)

tanh

(tanh q)

to-angles

(to-angles q)

Convert quaternion to Tait–Bryan angles, z-y′-x".

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.

to-rotation-matrix

(to-rotation-matrix q)

Convert quaternion to rotation 3x3 matrix

vector

(vector quaternion)

Returns vector part of quaternion, Vec3 type

ZERO

zero?

(zero? quaternion)

Is zero?