gl-quat
Part of a fork of @toji's gl-matrix split into smaller pieces: this package contains
glMatrix.quat
.Usage
quat = require('gl-quat')
Will load all of the module's functionality and expose it on a single
object. Note that any of the methods may also be required directly
from their files.For example, the following are equivalent:
var slerp = require('gl-quat').slerp
var slerp = require('gl-quat/slerp')
API
- add() - calculateW() - copy() - conjugate() - copy() - create() - dot() - fromMat3() - fromValues() - identity() - invert() - length() - lerp() - multiply() - normalize() - rotateX() - rotateY() - rotateZ() - rotationTo() - scale() - set() - setAxes() - setAxisAngle() - slerp() - sqlerp() - squaredLength()calculateW(out:quat, 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.add(out:quat, a:quat, b:quat)
Adds two quat'sconjugate(out:quat, 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.copy(out:quat, a:quat)
Copy the values from one quat to anothercreate()
Creates a new identity quatdot(a:quat, b:quat)
Calculates the dot product of two quat'sfromMat3(out:quat, m:mat3)
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.
fromValues(x:Number, y:Number, z:Number, w:Number)
identity(out:quat)
Set a quat to the identity quaternioninvert(out:quat, a:quat)
Calculates the inverse of a quatlength(a:quat)
Calculates the length of a quatlerp(out:quat, a:quat, b:quat, t:Number)
Performs a linear interpolation between two quat'smultiply(out:quat, a:quat, b:quat)
Multiplies two quat'snormalize(out:quat, a:quat)
Normalize a quatrotateX(out:quat, a:quat, rad:number)
Rotates a quaternion by the given angle about the X axisrotateY(out:quat, a:quat, rad:number)
Rotates a quaternion by the given angle about the Y axisrotateZ(out:quat, a:quat, rad:number)
Rotates a quaternion by the given angle about the Z axisrotationTo(out:quat, a:vec3, b:vec3)
Sets a quaternion to represent the shortest rotation from one vector to another.Both vectors are assumed to be unit length.