Module: quat

Summary

Methods

Detailed Description

Methods

add(a, b, out) → {Quat}

Adds two quat's
Parameters:
Name Type Description
a Quat the first operand
b Quat the second operand
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

calculateW(a, out) → {Quat}

Calculates the W component of a quat from the X, Y, and Z components. Assumes that quaternion is 1 unit in length. Any existing W component will be ignored.
Parameters:
Name Type Description
a Quat quat to calculate W component of
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

clone(a) → {Quat}

Creates a new quat initialized with values from an existing quaternion
Parameters:
Name Type Description
a Quat quaternion to clone
Returns:
a new quaternion
Type
Quat
Source:

conjugate(a, out) → {Quat}

Calculates the conjugate of a quat If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
Parameters:
Name Type Description
a Quat quat to calculate conjugate of
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

copy(a, out) → {Quat}

Copy the values from one quat to another
Parameters:
Name Type Description
a Quat the source quaternion
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

create() → {Quat}

Creates a new identity quat
Returns:
a new quaternion
Type
Quat
Source:

dot(a, b) → {Number}

Calculates the dot product of two quat's
Parameters:
Name Type Description
a Quat the first operand
b Quat the second operand
Returns:
dot product of a and b
Type
Number
Source:

fromMat3(m, out) → {Quat}

Creates a quaternion from the given 3x3 rotation matrix. NOTE: The resultant quaternion is not normalized, so you should be sure to renormalize the quaternion yourself where necessary.
Parameters:
Name Type Description
m Mat3 rotation matrix
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

fromValues(x, y, z, w) → {Quat}

Creates a new quat initialized with the given values
Parameters:
Name Type Description
x Number X component
y Number Y component
z Number Z component
w Number W component
Returns:
a new quaternion
Type
Quat
Source:

identity(out) → {Quat}

Set a quat to the identity quaternion
Parameters:
Name Type Description
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

invert(a, out) → {Quat}

Calculates the inverse of a quat
Parameters:
Name Type Description
a Quat quat to calculate inverse of
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

len()

Alias for quat.length
Source:

length(a) → {Number}

Calculates the length of a quat
Parameters:
Name Type Description
a Quat vector to calculate length of
Returns:
length of a
Type
Number
Source:

lerp(a, b, t, out) → {Quat}

Performs a linear interpolation between two quat's
Parameters:
Name Type Description
a Quat the first operand
b Quat the second operand
t Number interpolation amount between the two inputs
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

mul()

Alias for quat.multiply
Source:

multiply(a, b, out) → {Quat}

Multiplies two quat's
Parameters:
Name Type Description
a Quat the first operand
b Quat the second operand
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

normalize(a, out) → {Quat}

Normalize a quat
Parameters:
Name Type Description
a Quat quaternion to normalize
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

rotateX(a, rad, out) → {Quat}

Rotates a quaternion by the given angle about the X axis
Parameters:
Name Type Description
a Quat quat to rotate
rad number angle (in radians) to rotate
out Quat quat receiving operation result
Returns:
out
Type
Quat
Source:

rotateY(a, rad, out) → {Quat}

Rotates a quaternion by the given angle about the Y axis
Parameters:
Name Type Description
a Quat quat to rotate
rad number angle (in radians) to rotate
out Quat quat receiving operation result
Returns:
out
Type
Quat
Source:

rotateZ(a, rad, out) → {Quat}

Rotates a quaternion by the given angle about the Z axis
Parameters:
Name Type Description
a Quat quat to rotate
rad number angle (in radians) to rotate
out Quat quat receiving operation result
Returns:
out
Type
Quat
Source:

rotationTo(a, b, out) → {Quat}

Sets a quaternion to represent the shortest rotation from one vector to another. Both vectors are assumed to be unit length.
Parameters:
Name Type Description
a Vec3 the initial vector
b Vec3 the destination vector
out Quat the receiving quaternion.
Returns:
out
Type
Quat
Source:

scale(a, b, out) → {Quat}

Scales a quat by a scalar number
Parameters:
Name Type Description
a Quat the vector to scale
b Number amount to scale the vector by
out Quat the receiving vector
Returns:
out
Type
Quat
Source:

set(x, y, z, w, out) → {Quat}

Set the components of a quat to the given values
Parameters:
Name Type Description
x Number X component
y Number Y component
z Number Z component
w Number W component
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

setAxes(view, right, up) → {Quat}

Sets the specified quaternion with values corresponding to the given axes. Each axis is a vec3 and is expected to be unit length and perpendicular to all other specified axes.
Parameters:
Name Type Description
view Vec3 the vector representing the viewing direction
right Vec3 the vector representing the local "right" direction
up Vec3 the vector representing the local "up" direction
Returns:
out
Type
Quat
Source:

setAxisAngle(axis, rad, out) → {Quat}

Sets a quat from the given angle and rotation axis, then returns it.
Parameters:
Name Type Description
axis Vec3 the axis around which to rotate
rad Number the angle in radians
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

slerp(a, b, t, out) → {Quat}

Performs a spherical linear interpolation between two quat
Parameters:
Name Type Description
a Quat the first operand
b Quat the second operand
t Number interpolation amount between the two inputs
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

sqlerp(a, b, c, d, t, out) → {Quat}

Performs a spherical linear interpolation with two control points
Parameters:
Name Type Description
a Quat the first operand
b Quat the second operand
c Quat the third operand
d Quat the fourth operand
t Number interpolation amount
out Quat the receiving quaternion
Returns:
out
Type
Quat
Source:

sqrLen()

Alias for quat.squaredLength
Source:

squaredLength(a) → {Number}

Calculates the squared length of a quat
Parameters:
Name Type Description
a Quat vector to calculate squared length of
Returns:
squared length of a
Type
Number
Source:

str(vec) → {String}

Returns a string representation of a quatenion
Parameters:
Name Type Description
vec Quat vector to represent as a string
Returns:
string representation of the vector
Type
String
Source: