The goog.vec.Quaternion Namespace

.AnyType

@typedef
{goog.vec.AnyType}

.Float32

@typedef
{goog.vec.Float32}

.Float64

@typedef
{goog.vec.Float64}

.Number

@typedef
{goog.vec.Number}

.add

Adds the two quaternions.

quat0 {goog.vec.Quaternion.AnyType}
The first addend.
quat1 {goog.vec.Quaternion.AnyType}
The second addend.
resultQuat {goog.vec.Quaternion.AnyType}
The quaternion to receive the result. May be quat0 or quat1.

.cloneFloat32

Creates a clone of the given Float32 quaternion.

q {goog.vec.Quaternion.Float32}
The source quaternion.
returns {goog.vec.Quaternion.Float32}
The new quaternion.

.cloneFloat64

Creates a clone of the given Float64 quaternion.

q {goog.vec.Quaternion.Float64}
The source quaternion.
returns {goog.vec.Quaternion.Float64}
The new quaternion.

.concat(quat0, quat1, resultQuat)

Concatenates the two quaternions storing the result into resultQuat.

quat0 {goog.vec.Quaternion.AnyType}
The first quaternion.
quat1 {goog.vec.Quaternion.AnyType}
The second quaternion.
resultQuat {goog.vec.Quaternion.AnyType}
The quaternion to receive the result.
returns {!goog.vec.Quaternion.AnyType}
Return q so that operations can be chained together.

.conjugate(quat, resultQuat)

Computes the conjugate of the quaternion in quat storing the result into resultQuat.

quat {goog.vec.Quaternion.AnyType}
The source quaternion.
resultQuat {goog.vec.Quaternion.AnyType}
The quaternion to receive the result.
returns {!goog.vec.Quaternion.AnyType}
Return q so that operations can be chained together.

.createFloat32

Creates a Float32 quaternion, initialized to zero.

returns {!goog.vec.Quaternion.Float32}
The new quaternion.

.createFloat32FromArray

Creates a new Float32 quaternion initialized with the values from the supplied array.

vec {goog.vec.AnyType}
The source 4 element array.
returns {!goog.vec.Quaternion.Float32}
The new quaternion.

.createFloat32FromValues

Creates a new Float32 quaternion initialized with the supplied values.

v0 {number}
The value for element at index 0.
v1 {number}
The value for element at index 1.
v2 {number}
The value for element at index 2.
v3 {number}
The value for element at index 3.
returns {!goog.vec.Quaternion.Float32}
The new quaternion.

.createFloat64

Creates a Float64 quaternion, initialized to zero.

returns {goog.vec.Quaternion.Float64}
The new quaternion.

.createFloat64FromArray

Creates a new Float64 quaternion initialized with the values from the supplied array.

vec {goog.vec.AnyType}
The source 4 element array.
returns {!goog.vec.Quaternion.Float64}
The new quaternion.

.createFloat64FromValues

Creates a new Float64 quaternion initialized with the supplied values.

v0 {number}
The value for element at index 0.
v1 {number}
The value for element at index 1.
v2 {number}
The value for element at index 2.
v3 {number}
The value for element at index 3.
returns {!goog.vec.Quaternion.Float64}
The new quaternion.

.createNumber

Creates a Number quaternion, initialized to zero.

returns {goog.vec.Quaternion.Number}
The new quaternion.

.dot

Computes the dot (scalar) product of two quaternions.

q0 {goog.vec.Quaternion.AnyType}
The first quaternion.
q1 {goog.vec.Quaternion.AnyType}
The second quaternion.
returns {number}
The scalar product.

.fromAngleAxis(angle, axis, quat)

Generates a unit quaternion from the given angle-axis rotation pair. The rotation axis is not required to be a unit vector, but should have non-zero length. The angle should be specified in radians.

angle {number}
The angle (in radians) to rotate about the axis.
axis {goog.vec.Quaternion.AnyType}
Unit vector specifying the axis of rotation.
quat {goog.vec.Quaternion.AnyType}
Unit quaternion to store the result.
returns {goog.vec.Quaternion.AnyType}
Return q so that operations can be chained together.

.fromRotationMatrix4(matrix, quat)

Generates the quaternion from the given rotation matrix.

matrix {goog.vec.Quaternion.AnyType}
The source matrix.
quat {goog.vec.Quaternion.AnyType}
The resulting quaternion.
returns {!goog.vec.Quaternion.AnyType}
Return q so that operations can be chained together.

.magnitude

Returns the magnitude of the given quaternion.

quat0 {goog.vec.Quaternion.AnyType}
The quaternion.
returns {number}
The magnitude of the quaternion.

.magnitudeSquared

Returns the square magnitude of the given quaternion.

quat0 {goog.vec.Quaternion.AnyType}
The quaternion.
returns {number}
The magnitude of the quaternion.

.negate

Negates a quaternion, storing the result into resultQuat.

quat0 {goog.vec.Quaternion.AnyType}
The quaternion to negate.
resultQuat {goog.vec.Quaternion.AnyType}
The quaternion to receive the result. May be quat0.

.nlerp

Compute the simple linear interpolation of the two quaternions q0 and q1 according to the coefficient t. The resulting quaternion is stored in resultVec.

q0 {goog.vec.Quaternion.AnyType}
The first quaternion.
q1 {goog.vec.Quaternion.AnyType}
The second quaternion.
t {number}
The interpolation factor.
resultQuat {goog.vec.Quaternion.AnyType}
The quaternion to receive the results (may be q0 or q1).

.normalize

Normalizes the given quaternion storing the result into resultVec.

quat0 {goog.vec.Quaternion.AnyType}
The quaternion to normalize.
resultQuat {goog.vec.Quaternion.AnyType}
The quaternion to receive the result. May be quat0.

.scale

Multiplies each component of quat0 with scalar storing the product into resultVec.

quat0 {goog.vec.Quaternion.AnyType}
The source quaternion.
scalar {number}
The value to multiply with each component of quat0.
resultQuat {goog.vec.Quaternion.AnyType}
The quaternion to receive the result. May be quat0.

.setFromArray

Initializes the quaternion with the given array of values.

q {goog.vec.Quaternion.AnyType}
The quaternion to receive the values.
values {goog.vec.AnyType}
The array of values.
returns {!goog.vec.Quaternion.AnyType}
return q so that operations can be chained together.

.setFromValues

Initializes the quaternion with the given values.

q {goog.vec.Quaternion.AnyType}
The quaternion to receive the values.
v0 {number}
The value for element at index 0.
v1 {number}
The value for element at index 1.
v2 {number}
The value for element at index 2.
v3 {number}
The value for element at index 3.
returns {!goog.vec.Vec4.AnyType}
return q so that operations can be chained together.

.slerp(q0, q1, t, resultQuat)

Computes the spherical linear interpolated value from the given quaternions q0 and q1 according to the coefficient t. The resulting quaternion is stored in resultQuat.

q0 {goog.vec.Quaternion.AnyType}
The first quaternion.
q1 {goog.vec.Quaternion.AnyType}
The second quaternion.
t {number}
The interpolating coefficient.
resultQuat {goog.vec.Quaternion.AnyType}
The quaternion to receive the result.
returns {goog.vec.Quaternion.AnyType}
Return q so that operations can be chained together.

.toAngleAxis(quat, axis)

Generates an angle-axis rotation pair from a unit quaternion. The quaternion is assumed to be of unit length. The calculated values are returned via the passed 'axis' object and the 'angle' number returned by the function itself. The returned rotation axis is a non-zero length unit vector, and the returned angle is in radians in the range of [-PI, +PI].

quat {goog.vec.Quaternion.AnyType}
Unit quaternion to convert.
axis {goog.vec.Quaternion.AnyType}
Vector to store the returned rotation axis.
returns {number}
angle Angle (in radians) to rotate about 'axis'. The range of the returned angle is [-PI, +PI].

.toRotationMatrix4(quat, matrix)

Generates the rotation matrix from the given quaternion.

quat {goog.vec.Quaternion.AnyType}
The source quaternion.
matrix {goog.vec.AnyType}
The resulting matrix.
returns {!goog.vec.AnyType}
Return resulting matrix so that operations can be chained together.