quat

quat()

Quaternion

Members

innerequals$7

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

innerexactEquals$6

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

innerlength$2

Calculates the length of a quat

innerrotationTo

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

innersetAxes

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.

innersqlerp

Performs a spherical linear interpolation with two control points

Methods

inneradd$6(out, a, b)quat

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

innercalculateW(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.
Name Type Description
out quat the receiving quaternion
a quat quat to calculate W component of
Returns:
out

innerclone$6(a)quat

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

innerconjugate(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.
Name Type Description
out quat the receiving quaternion
a quat quat to calculate conjugate of
Returns:
out

innercopy$6(out, a)quat

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

innercreate$6()quat

Creates a new identity quat
Returns:
a new quaternion

innerdot$2(a, b)Number

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

innerexp(out, a)quat

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

innerfromEuler(out, Angle, Angle, Angle)quat

Creates a quaternion from the given euler angle x, y, z.
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.
Returns:
out

innerfromMat3(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.
Name Type Description
out quat the receiving quaternion
m mat3 rotation matrix
Returns:
out

innerfromValues$6(x, y, z, w)quat

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

innergetAngle(a, b)Number

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

innergetAxisAngle(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.
Name Type Description
out_axis vec3 Vector receiving the axis of rotation
q quat Quaternion to be decomposed
Returns:
Angle, in radians, of the rotation

inneridentity$4(out)quat

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

innerinvert$4(out, a)quat

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

innerlen$2()

Alias for quat.length

innerlerp$2(out, a, b, t)quat

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

innerln(out, a)quat

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

innermul$6()

Alias for quat.multiply

innermultiply$6(out, a, b)quat

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

innernormalize$2(out, a)quat

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

innerpow(out, a, b)quat

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

innerrandom$2(out)quat

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

innerrotateX$2(out, a, rad)quat

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

innerrotateY$2(out, a, rad)quat

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

innerrotateZ$2(out, a, rad)quat

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

innerscale$6(out, a, b)quat

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

innerset$6(out, x, y, z, w)quat

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

innersetAxisAngle(out, axis, rad)quat

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

innerslerp(out, a, b, t)quat

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

innersqrLen$2()

Alias for quat.squaredLength

innersquaredLength$2(a)Number

Calculates the squared length of a quat
Name Type Description
a quat vector to calculate squared length of
Returns:
squared length of a

innerstr$6(a)String

Returns a string representation of a quatenion
Name Type Description
a quat vector to represent as a string
Returns:
string representation of the vector