e2 docs quaternion - wiremod/wire GitHub Wiki

Jump to table of contents

Quaternion

Quaternion = quat()

Creates a zero quaternion (1 ops)

Quaternion = quat(Number Real)

Creates a quaternion with real part equal to N (1 ops)

Quaternion = quat(ComplexNumber C)

Creates a quaternion with real and "i" parts equal to C (1 ops)

Quaternion = quat(Vector Imag)

Converts a vector to a quaternion (returns V.xi + V.yj + V.z*k) (1 ops)

Quaternion = quat(Number Real, Number I, Number J, Number K)

Returns N+N2i+N3j+N4k (1 ops)

Quaternion = quat(Angle Ang)

Converts A to a quaternion (6 ops)

Quaternion = quat(Vector Forward, Vector Up)

Creates a quaternion given forward (V) and up (V2) vectors (15 ops)

Quaternion = quat(Entity Ent)

Converts angle of E to a quaternion (15 ops)

Quaternion = qi()

Returns quaternion i (1 ops)

Quaternion = qi(Number N)

Returns quaternion N*i (1 ops)

Quaternion = qj()

Returns j (1 ops)

Quaternion = qj(Number N)

Returns N*j (1 ops)

Quaternion = qk()

Returns k (1 ops)

Quaternion = qk(Number N)

Returns N*k (1 ops)

Number = abs(Quaternion Q)

Returns absolute value of Q (4 ops)

Quaternion = conj(Quaternion Q)

Returns the conjugate of Q (4 ops)

Quaternion = inv(Quaternion Q)

Returns the inverse of Q (4 ops)

Number = Quaternion:real()

Returns the real component of the quaternion (1 ops)

Number = Quaternion:i()

Returns the i component of the quaternion (1 ops)

Number = Quaternion:j()

Returns the j component of the quaternion (1 ops)

Number = Quaternion:k()

Returns the k component of the quaternion (1 ops)

Quaternion = exp(Quaternion Q)

Raises Euler's constant e to the power Q (7 ops)

Quaternion = log(Quaternion Q)

Calculates natural logarithm of Q (7 ops)

Quaternion = qMod(Quaternion Q)

Changes quaternion Q so that the represented rotation is by an angle between 0 and 180 degrees (by coder0xff) (2 ops)

Quaternion = slerp(Quaternion Q0, Quaternion Q1, Number T)

Performs spherical linear interpolation between Q and Q2. Returns Q for N=0, Q2 for N=1 (13 ops)

Quaternion = nlerp(Quaternion Q0, Quaternion Q1, Number T)

Performs linear interpolation between Q and Q2. Returns normalized Q for N=0, Q2 for N=1. (13 ops)

Vector = Quaternion:forward()

Returns vector pointing forward for Q (7 ops)

Vector = Quaternion:right()

Returns vector pointing right for Q (7 ops)

Vector = Quaternion:up()

Returns vector pointing up for Q (7 ops)

Quaternion = qRotation(Vector Axis, Number Ang)

Returns quaternion for rotation about axis V by angle N (9 ops)

Quaternion = qRotation(Vector Rv1)

Construct a quaternion from the rotation vector V. Vector direction is axis of rotation, magnitude is angle in degress (by coder0xff) (9 ops)

Number = rotationAngle(Quaternion Q)

Returns the angle of rotation in degrees (by coder0xff) (9 ops)

Vector = rotationAxis(Quaternion Q)

Returns the axis of rotation (by coder0xff) (9 ops)

Vector = rotationVector(Quaternion Q)

Returns the rotation vector - rotation axis where magnitude is the angle of rotation in degress (by coder0xff) (9 ops)

Vector = vec(Quaternion Q)

Converts Q to a vector by dropping the real component (3 ops)

Matrix = matrix(Quaternion Q)

Converts Q to a transformation matrix (15 ops)

Angle = Quaternion:toAngle()

Returns angle represented by Q (15 ops)

Quaternion = Quaternion:normalized()

Returns new normalized quaternion for Q (15 ops)

Number = Quaternion:dot(Quaternion Q1)

Returns dot product of Q with Q2 (15 ops)

String = toString(Quaternion Q)

Formats Q as a string (15 ops)

String = Quaternion:toString()

Formats Q as a string (15 ops)