Skip to main content

Quaternion

Quaternion

Kind: global class

new Quaternion([x], [y], [z], [w])

ParamTypeDefault
[x]number0
[y]number0
[z]number0
[w]number1

quaternion.x : number

Kind: instance property of Quaternion

quaternion.y : number

Kind: instance property of Quaternion

quaternion.z : number

Kind: instance property of Quaternion

quaternion.w : number

Kind: instance property of Quaternion

quaternion.onChanged : Signal.<number, number, number, number, number, number, number, number>

Kind: instance property of Quaternion
Read only: true

quaternion._lookRotation(fx, fy, fz, ux, uy, uz)

Kind: instance method of Quaternion

ParamTypeDescription
fxnumberforward vector
fynumberforward vector
fznumberforward vector
uxnumberup vector
uynumberup vector
uznumberup vector

quaternion.lookRotation(vForward, [vUp])

Kind: instance method of Quaternion

ParamTypeDefault
vForwardVector3
[vUp]Vector3Vector3.up

quaternion.dot(other) ⇒ number

Kind: instance method of Quaternion

ParamType
otherQuaternion

quaternion.copyInverse(other)

Makes this quaternion into an inverse of the other

Kind: instance method of Quaternion

ParamType
otherQuaternion

quaternion.invert()

Calculates the inverse

Kind: instance method of Quaternion

quaternion.angleTo(other) ⇒ number

Returns angle between this orientation and another

Kind: instance method of Quaternion
Returns: number - angle in radians

ParamType
otherQuaternion

quaternion.fromAxisAngle(axis, angle)

Kind: instance method of Quaternion

ParamType
axisVector3
anglenumber

quaternion._fromAxisAngle(ax, ay, az, angle)

Kind: instance method of Quaternion

ParamType
axnumber
aynumber
aznumber
anglenumber

quaternion.computeSwingAndTwist(axis, swing, twist)

Kind: instance method of Quaternion
See: https://stackoverflow.com/questions/3684269/component-of-a-quaternion-rotation-around-an-axis

ParamType
axisVector3
swingQuaternion
twistQuaternion

quaternion.computeTwistAngle(axis) ⇒ number

Compute rotation (twist) around input axis

Kind: instance method of Quaternion
Returns: number - in radians

ParamType
axisVector3

quaternion.toAxisAngle(axis) ⇒ number

Kind: instance method of Quaternion
Returns: number - angle in radians

ParamType
axisVector3

quaternion.multiplyScalar(val) ⇒ Quaternion

Kind: instance method of Quaternion

ParamType
valnumber

quaternion.multiply(other)

Kind: instance method of Quaternion

ParamType
otherQuaternion

quaternion.multiplyQuaternions(first, second)

Kind: instance method of Quaternion

ParamType
firstQuaternion
secondQuaternion

quaternion._multiplyQuaternions(ax, ay, az, aw, bx, by, bz, bw) ⇒ Quaternion

Kind: instance method of Quaternion

ParamType
axnumber
aynumber
aznumber
awnumber
bxnumber
bynumber
bznumber
bwnumber

quaternion.length() ⇒ number

Kind: instance method of Quaternion

quaternion.rotateTowards(other, max_delta)

Kind: instance method of Quaternion

ParamTypeDescription
otherQuaternion
max_deltanumberin radians

quaternion.lookAt(source, target, [up])

Kind: instance method of Quaternion

ParamType
sourceVector3
targetVector3
[up]Vector3

quaternion.setRandom(random)

Kind: instance method of Quaternion

ParamType
randomfunction

quaternion.__setFromEuler(x, y, z, [order]) ⇒ Quaternion

Kind: instance method of Quaternion

ParamTypeDefaultDescription
xnumber
ynumber
znumber
[order]StringXYZa combination of capital letters X,Y,Z. Examples: XYZ, YXZ

quaternion.toEulerAnglesXYZ(result)

Kind: instance method of Quaternion
See

ParamType
resultVector3

quaternion.toEulerAnglesYXZ(result)

Adapted from http://bediyap.com/programming/convert-quaternion-to-euler-rotations/

Kind: instance method of Quaternion

ParamType
resultVector3

quaternion.toEulerAnglesZYX(result)

Adapted from http://bediyap.com/programming/convert-quaternion-to-euler-rotations/

Kind: instance method of Quaternion

ParamType
resultVector3

quaternion.fromEulerAnglesXYZ(x, y, z)

XYZ order

Kind: instance method of Quaternion
Source:: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
See

ParamTypeDescription
xnumberangle in X axis in radians
ynumberangle in Y axis in radians
znumberangle in Z axis in radians

quaternion.fromEulerAnglesYXZ(x, y, z)

XYZ order

Kind: instance method of Quaternion
Source:: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
See

ParamTypeDescription
xnumberangle in X axis in radians
ynumberangle in Y axis in radians
znumberangle in Z axis in radians

quaternion.fromEulerAnglesZXY(x, y, z)

XYZ order

Kind: instance method of Quaternion
Source:: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
See

ParamTypeDescription
xnumberangle in X axis in radians
ynumberangle in Y axis in radians
znumberangle in Z axis in radians

quaternion.fromEulerAnglesZYX(x, y, z)

XYZ order

Kind: instance method of Quaternion
Source:: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
See

ParamTypeDescription
xnumberangle in X axis in radians
ynumberangle in Y axis in radians
znumberangle in Z axis in radians

quaternion.fromEulerAnglesYZX(x, y, z)

XYZ order

Kind: instance method of Quaternion
Source:: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
See

ParamTypeDescription
xnumberangle in X axis in radians
ynumberangle in Y axis in radians
znumberangle in Z axis in radians

quaternion.fromEulerAnglesXZY(x, y, z)

XYZ order

Kind: instance method of Quaternion
Source:: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
See

ParamTypeDescription
xnumberangle in X axis in radians
ynumberangle in Y axis in radians
znumberangle in Z axis in radians

quaternion.fromUnitVectors(from, to)

NOTE: Vectors need to be normalized Based on blog post: http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors

Kind: instance method of Quaternion

ParamType
fromVector3
toVector3

quaternion.setFromRotationMatrix(m)

Deprecated

Kind: instance method of Quaternion

ParamType
mMatrix4

quaternion.__setFromRotationMatrix(m11, m12, m13, m21, m22, m23, m31, m32, m33) ⇒ Quaternion

This algorithm comes from "Quaternion Calculus and Fast Animation", Ken Shoemake, 1987 SIGGRAPH course notes

Kind: instance method of Quaternion
See: https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Geometry/Quaternion.h#L813

ParamType
m11number
m12number
m13number
m21number
m22number
m23number
m31number
m32number
m33number

quaternion.lerp(other, t)

Linear interpolation

Kind: instance method of Quaternion

ParamTypeDescription
otherQuaternion
tnumberfractional value between 0 and 1

quaternion.lerpQuaternions(first, second, t)

Kind: instance method of Quaternion

ParamType
firstQuaternion
secondQuaternion
tnumber

quaternion.slerpQuaternions(from, to, t)

Kind: instance method of Quaternion

ParamType
fromQuaternion
toQuaternion
tnumber

quaternion.slerp(other, t)

Kind: instance method of Quaternion
See: https://github.com/toji/gl-matrix/blob/master/src/gl-matrix/quat.js

ParamType
otherQuaternion
tnumber

quaternion.process(handler)

Kind: instance method of Quaternion

ParamType
handlerfunction

quaternion.copy(other) ⇒ Quaternion

Kind: instance method of Quaternion

ParamType
otherQuaternion

quaternion.clone() ⇒ Quaternion

Kind: instance method of Quaternion

quaternion.set(x, y, z, w) ⇒ Quaternion

Kind: instance method of Quaternion

ParamType
xnumber
ynumber
znumber
wnumber

quaternion.conjugate() ⇒ Quaternion

Kind: instance method of Quaternion

quaternion.toBinaryBuffer(buffer)

Kind: instance method of Quaternion

ParamType
bufferBinaryBuffer

quaternion.fromBinaryBuffer(buffer)

Kind: instance method of Quaternion

ParamType
bufferBinaryBuffer

quaternion.toBinaryBufferFloat32(buffer)

Kind: instance method of Quaternion

ParamType
bufferBinaryBuffer

quaternion.fromBinaryBufferFloat32(buffer)

Kind: instance method of Quaternion

ParamType
bufferBinaryBuffer

quaternion.decodeFromUint32(value)

Deprecated

Based on GDC talk from Bungie on destiny, compressing quaternions for animation

Kind: instance method of Quaternion

ParamType
valuenumber

quaternion.encodeToUint32() ⇒ number

Deprecated

Based on GDC talk from Bungie on destiny, compressing quaternions for animation

Kind: instance method of Quaternion

quaternion.readFromArray(array, offset)

Kind: instance method of Quaternion

ParamTypeDefault
arrayArray.<number>
offsetnumber0

quaternion.writeToArray([array], [offset]) ⇒ Array.<number>

Kind: instance method of Quaternion

ParamTypeDefault
[array]Array.<number>
[offset]number0

quaternion.equals(other) ⇒ boolean

Kind: instance method of Quaternion

ParamType
otherQuaternion

quaternion.hash() ⇒ number

Kind: instance method of Quaternion

quaternion.roughlyEquals(other, [tolerance]) ⇒ boolean

Kind: instance method of Quaternion

ParamType
otherQuaternion
[tolerance]number

quaternion.random([random]) ⇒ Quaternion

Based on http://planning.cs.uiuc.edu/node198.html

Kind: instance method of Quaternion

ParamType
[random]function

Quaternion.identity : Quaternion

Kind: static property of Quaternion
Read only: true

Quaternion.random(random) ⇒ Quaternion

Kind: static method of Quaternion

ParamTypeDescription
randomfunctionrandom number generator function

Quaternion.fromEulerAngles(x, y, z) ⇒ Quaternion

Kind: static method of Quaternion

ParamTypeDescription
xnumberin radians
ynumberin radians
znumberin radians

Quaternion.rotateTowards(result, from, to, max_delta)

Behaves similarly to Unity's Quaternion RotateToward method

Kind: static method of Quaternion

ParamTypeDescription
resultQuaternion
fromQuaternion
toQuaternion
max_deltanumberin radians