Module: quat

Quaternion
Source:

Members

(static, constant) equals

Returns whether or not the quaternions have approximately the same elements in the same position.
Source:

(static, constant) exactEquals

Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
Source:

(static, constant) length

Calculates the length of a quat
Source:

(static, constant) rotationTo

Sets a quaternion to represent the shortest rotation from one vector to another.Both vectors are assumed to be unit length.
Source:

(static, constant) setAxes

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.
Source:

(static, constant) sqlerp

Performs a spherical linear interpolation with two control points
Source:

Methods

(static) add(out, a, b) → {quat}

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

(static) calculateW(out, a) → {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
out quat the receiving quaternion
a ReadonlyQuat quat to calculate W component of
Source:
Returns:
out
Type
quat

(static) clone(a) → {quat}

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

(static) conjugate(out, a) → {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
out quat the receiving quaternion
a ReadonlyQuat quat to calculate conjugate of
Source:
Returns:
out
Type
quat

(static) copy(out, a) → {quat}

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

(static) create() → {quat}

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

(static) dot(a, b) → {Number}

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

(static) exp(out, a) → {quat}

Calculate the exponential of a unit quaternion.
Parameters:
Name Type Description
out quat the receiving quaternion
a ReadonlyQuat quat to calculate the exponential of
Source:
Returns:
out
Type
quat

(static) fromEuler(out, Angle, Angle, Angle) → {quat}

Creates a quaternion from the given euler angle x, y, z.
Parameters:
Name Type Description
out quat the receiving quaternion
Angle x to rotate around X axis in degrees.
Angle y to rotate around Y axis in degrees.
Angle z to rotate around Z axis in degrees.
Source:
Returns:
out
Type
quat

(static) fromMat3(out, m) → {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
out quat the receiving quaternion
m ReadonlyMat3 rotation matrix
Source:
Returns:
out
Type
quat

(static) 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
Source:
Returns:
a new quaternion
Type
quat

(static) getAngle(a, b) → {Number}

Gets the angular distance between two unit quaternions
Parameters:
Name Type Description
a ReadonlyQuat Origin unit quaternion
b ReadonlyQuat Destination unit quaternion
Source:
Returns:
Angle, in radians, between the two quaternions
Type
Number

(static) getAxisAngle(out_axis, q) → {Number}

Gets the rotation axis and angle for a given quaternion. If a quaternion is created with setAxisAngle, this method will return the same values as providied in the original parameter list OR functionally equivalent values.Example: The quaternion formed by axis [0, 0, 1] and angle -90 is the same as the quaternion formed by [0, 0, 1] and 270. This method favors the latter.
Parameters:
Name Type Description
out_axis vec3 Vector receiving the axis of rotation
q ReadonlyQuat Quaternion to be decomposed
Source:
Returns:
Angle, in radians, of the rotation
Type
Number

(static) identity(out) → {quat}

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

(static) invert(out, a) → {quat}

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

(static) len()

Alias for quat.length
Source:

(static) lerp(out, a, b, t) → {quat}

Performs a linear interpolation between two quat's
Parameters:
Name Type Description
out quat the receiving quaternion
a ReadonlyQuat the first operand
b ReadonlyQuat the second operand
t Number interpolation amount, in the range [0-1], between the two inputs
Source:
Returns:
out
Type
quat

(static) ln(out, a) → {quat}

Calculate the natural logarithm of a unit quaternion.
Parameters:
Name Type Description
out quat the receiving quaternion
a ReadonlyQuat quat to calculate the exponential of
Source:
Returns:
out
Type
quat

(static) mul()

Alias for quat.multiply
Source:

(static) multiply(out, a, b) → {quat}

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

(static) normalize(out, a) → {quat}

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

(static) pow(out, a, b) → {quat}

Calculate the scalar power of a unit quaternion.
Parameters:
Name Type Description
out quat the receiving quaternion
a ReadonlyQuat quat to calculate the exponential of
b Number amount to scale the quaternion by
Source:
Returns:
out
Type
quat

(static) random(out) → {quat}

Generates a random unit quaternion
Parameters:
Name Type Description
out quat the receiving quaternion
Source:
Returns:
out
Type
quat

(static) rotateX(out, a, rad) → {quat}

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

(static) rotateY(out, a, rad) → {quat}

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

(static) rotateZ(out, a, rad) → {quat}

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

(static) scale(out, a, b) → {quat}

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

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

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

(static) setAxisAngle(out, axis, rad) → {quat}

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

(static) slerp(out, a, b, t) → {quat}

Performs a spherical linear interpolation between two quat
Parameters:
Name Type Description
out quat the receiving quaternion
a ReadonlyQuat the first operand
b ReadonlyQuat the second operand
t Number interpolation amount, in the range [0-1], between the two inputs
Source:
Returns:
out
Type
quat

(static) sqrLen()

Alias for quat.squaredLength
Source:

(static) squaredLength(a) → {Number}

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

(static) str(a) → {String}

Returns a string representation of a quaternion
Parameters:
Name Type Description
a ReadonlyQuat vector to represent as a string
Source:
Returns:
string representation of the vector
Type
String