Quaternion
Quaternion
Kind: global class
- Quaternion
- new Quaternion([x], [y], [z], [w])
- instance
- .x :
number
- .y :
number
- .z :
number
- .w :
number
- .onChanged :
Signal.<number, number, number, number, number, number, number, number>
- ._lookRotation(fx, fy, fz, ux, uy, uz)
- .lookRotation(vForward, [vUp])
- .dot(other) ⇒
number
- .copyInverse(other)
- .invert()
- .angleTo(other) ⇒
number
- .fromAxisAngle(axis, angle)
- ._fromAxisAngle(ax, ay, az, angle)
- .computeSwingAndTwist(axis, swing, twist)
- .computeTwistAngle(axis) ⇒
number
- .toAxisAngle(axis) ⇒
number
- .multiplyScalar(val) ⇒
Quaternion
- .multiply(other)
- .multiplyQuaternions(first, second)
- ._multiplyQuaternions(ax, ay, az, aw, bx, by, bz, bw) ⇒
Quaternion
- .length() ⇒
number
- .rotateTowards(other, max_delta)
- .lookAt(source, target, [up])
- .setRandom(random)
- .__setFromEuler(x, y, z, [order]) ⇒
Quaternion
- .toEulerAnglesXYZ(result)
- .toEulerAnglesYXZ(result)
- .toEulerAnglesZYX(result)
- .fromEulerAnglesXYZ(x, y, z)
- .fromEulerAnglesYXZ(x, y, z)
- .fromEulerAnglesZXY(x, y, z)
- .fromEulerAnglesZYX(x, y, z)
- .fromEulerAnglesYZX(x, y, z)
- .fromEulerAnglesXZY(x, y, z)
- .fromUnitVectors(from, to)
.setFromRotationMatrix(m)- .__setFromRotationMatrix(m11, m12, m13, m21, m22, m23, m31, m32, m33) ⇒
Quaternion
- .lerp(other, t)
- .lerpQuaternions(first, second, t)
- .slerpQuaternions(from, to, t)
- .slerp(other, t)
- .process(handler)
- .copy(other) ⇒
Quaternion
- .clone() ⇒
Quaternion
- .set(x, y, z, w) ⇒
Quaternion
- .conjugate() ⇒
Quaternion
- .toBinaryBuffer(buffer)
- .fromBinaryBuffer(buffer)
- .toBinaryBufferFloat32(buffer)
- .fromBinaryBufferFloat32(buffer)
.decodeFromUint32(value).encodeToUint32() ⇒number
- .readFromArray(array, offset)
- .writeToArray([array], [offset]) ⇒
Array.<number>
- .equals(other) ⇒
boolean
- .hash() ⇒
number
- .roughlyEquals(other, [tolerance]) ⇒
boolean
- .random([random]) ⇒
Quaternion
- .x :
- static
new Quaternion([x], [y], [z], [w])
Param | Type | Default |
---|---|---|
[x] | number | 0 |
[y] | number | 0 |
[z] | number | 0 |
[w] | number | 1 |
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
Param | Type | Description |
---|---|---|
fx | number | forward vector |
fy | number | forward vector |
fz | number | forward vector |
ux | number | up vector |
uy | number | up vector |
uz | number | up vector |
quaternion.lookRotation(vForward, [vUp])
Kind: instance method of Quaternion
Param | Type | Default |
---|---|---|
vForward | Vector3 | |
[vUp] | Vector3 | Vector3.up |
quaternion.dot(other) ⇒ number
Kind: instance method of Quaternion
Param | Type |
---|---|
other | Quaternion |
quaternion.copyInverse(other)
Makes this quaternion into an inverse of the other
Kind: instance method of Quaternion
Param | Type |
---|---|
other | Quaternion |
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
Param | Type |
---|---|
other | Quaternion |
quaternion.fromAxisAngle(axis, angle)
Kind: instance method of Quaternion
Param | Type |
---|---|
axis | Vector3 |
angle | number |
quaternion._fromAxisAngle(ax, ay, az, angle)
Kind: instance method of Quaternion
Param | Type |
---|---|
ax | number |
ay | number |
az | number |
angle | number |
quaternion.computeSwingAndTwist(axis, swing, twist)
Kind: instance method of Quaternion
See: https://stackoverflow.com/questions/3684269/component-of-a-quaternion-rotation-around-an-axis
Param | Type |
---|---|
axis | Vector3 |
swing | Quaternion |
twist | Quaternion |
quaternion.computeTwistAngle(axis) ⇒ number
Compute rotation (twist) around input axis
Kind: instance method of Quaternion
Returns: number
- in radians
Param | Type |
---|---|
axis | Vector3 |
quaternion.toAxisAngle(axis) ⇒ number
Kind: instance method of Quaternion
Returns: number
- angle in radians
Param | Type |
---|---|
axis | Vector3 |
quaternion.multiplyScalar(val) ⇒ Quaternion
Kind: instance method of Quaternion
Param | Type |
---|---|
val | number |
quaternion.multiply(other)
Kind: instance method of Quaternion
Param | Type |
---|---|
other | Quaternion |
quaternion.multiplyQuaternions(first, second)
Kind: instance method of Quaternion
Param | Type |
---|---|
first | Quaternion |
second | Quaternion |
quaternion._multiplyQuaternions(ax, ay, az, aw, bx, by, bz, bw) ⇒ Quaternion
Kind: instance method of Quaternion
Param | Type |
---|---|
ax | number |
ay | number |
az | number |
aw | number |
bx | number |
by | number |
bz | number |
bw | number |
quaternion.length() ⇒ number
Kind: instance method of Quaternion
quaternion.rotateTowards(other, max_delta)
Kind: instance method of Quaternion
Param | Type | Description |
---|---|---|
other | Quaternion | |
max_delta | number | in radians |
quaternion.lookAt(source, target, [up])
Kind: instance method of Quaternion
Param | Type |
---|---|
source | Vector3 |
target | Vector3 |
[up] | Vector3 |
quaternion.setRandom(random)
Kind: instance method of Quaternion
Param | Type |
---|---|
random | function |
quaternion.__setFromEuler(x, y, z, [order]) ⇒ Quaternion
Kind: instance method of Quaternion
Param | Type | Default | Description |
---|---|---|---|
x | number | ||
y | number | ||
z | number | ||
[order] | String | XYZ | a combination of capital letters X,Y,Z. Examples: XYZ, YXZ |
quaternion.toEulerAnglesXYZ(result)
Kind: instance method of Quaternion
See
- https://localcoder.org/euler-angle-to-quaternion-then-quaternion-to-euler-angle
- https://discourse.mcneel.com/t/what-is-the-right-method-to-convert-quaternion-to-plane-using-rhinocommon/92411/21?page=2
Param | Type |
---|---|
result | Vector3 |
quaternion.toEulerAnglesYXZ(result)
Adapted from http://bediyap.com/programming/convert-quaternion-to-euler-rotations/
Kind: instance method of Quaternion
Param | Type |
---|---|
result | Vector3 |
quaternion.toEulerAnglesZYX(result)
Adapted from http://bediyap.com/programming/convert-quaternion-to-euler-rotations/
Kind: instance method of Quaternion
Param | Type |
---|---|
result | Vector3 |
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
- http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
- https://github.com/mrdoob/three.js/blob/510705cde208b165fd87946b0f8504a1cd6dbe83/src/math/Quaternion.js#L206
Param | Type | Description |
---|---|---|
x | number | angle in X axis in radians |
y | number | angle in Y axis in radians |
z | number | angle 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
- http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
- https://github.com/mrdoob/three.js/blob/510705cde208b165fd87946b0f8504a1cd6dbe83/src/math/Quaternion.js#L206
Param | Type | Description |
---|---|---|
x | number | angle in X axis in radians |
y | number | angle in Y axis in radians |
z | number | angle 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
- http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
- https://github.com/mrdoob/three.js/blob/510705cde208b165fd87946b0f8504a1cd6dbe83/src/math/Quaternion.js#L206
Param | Type | Description |
---|---|---|
x | number | angle in X axis in radians |
y | number | angle in Y axis in radians |
z | number | angle 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
- http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
- https://github.com/mrdoob/three.js/blob/510705cde208b165fd87946b0f8504a1cd6dbe83/src/math/Quaternion.js#L206
Param | Type | Description |
---|---|---|
x | number | angle in X axis in radians |
y | number | angle in Y axis in radians |
z | number | angle 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
- http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
- https://github.com/mrdoob/three.js/blob/510705cde208b165fd87946b0f8504a1cd6dbe83/src/math/Quaternion.js#L206
Param | Type | Description |
---|---|---|
x | number | angle in X axis in radians |
y | number | angle in Y axis in radians |
z | number | angle 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
- http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
- https://github.com/mrdoob/three.js/blob/510705cde208b165fd87946b0f8504a1cd6dbe83/src/math/Quaternion.js#L206
Param | Type | Description |
---|---|---|
x | number | angle in X axis in radians |
y | number | angle in Y axis in radians |
z | number | angle 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
Param | Type |
---|---|
from | Vector3 |
to | Vector3 |
quaternion.setFromRotationMatrix(m)
Deprecated
Kind: instance method of Quaternion
Param | Type |
---|---|
m | Matrix4 |
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
Param | Type |
---|---|
m11 | number |
m12 | number |
m13 | number |
m21 | number |
m22 | number |
m23 | number |
m31 | number |
m32 | number |
m33 | number |
quaternion.lerp(other, t)
Linear interpolation
Kind: instance method of Quaternion
Param | Type | Description |
---|---|---|
other | Quaternion | |
t | number | fractional value between 0 and 1 |
quaternion.lerpQuaternions(first, second, t)
Kind: instance method of Quaternion
Param | Type |
---|---|
first | Quaternion |
second | Quaternion |
t | number |
quaternion.slerpQuaternions(from, to, t)
Kind: instance method of Quaternion
Param | Type |
---|---|
from | Quaternion |
to | Quaternion |
t | number |
quaternion.slerp(other, t)
Kind: instance method of Quaternion
See: https://github.com/toji/gl-matrix/blob/master/src/gl-matrix/quat.js
Param | Type |
---|---|
other | Quaternion |
t | number |
quaternion.process(handler)
Kind: instance method of Quaternion
Param | Type |
---|---|
handler | function |
quaternion.copy(other) ⇒ Quaternion
Kind: instance method of Quaternion
Param | Type |
---|---|
other | Quaternion |
quaternion.clone() ⇒ Quaternion
Kind: instance method of Quaternion
quaternion.set(x, y, z, w) ⇒ Quaternion
Kind: instance method of Quaternion
Param | Type |
---|---|
x | number |
y | number |
z | number |
w | number |
quaternion.conjugate() ⇒ Quaternion
Kind: instance method of Quaternion
quaternion.toBinaryBuffer(buffer)
Kind: instance method of Quaternion
Param | Type |
---|---|
buffer | BinaryBuffer |
quaternion.fromBinaryBuffer(buffer)
Kind: instance method of Quaternion
Param | Type |
---|---|
buffer | BinaryBuffer |
quaternion.toBinaryBufferFloat32(buffer)
Kind: instance method of Quaternion
Param | Type |
---|---|
buffer | BinaryBuffer |
quaternion.fromBinaryBufferFloat32(buffer)
Kind: instance method of Quaternion
Param | Type |
---|---|
buffer | BinaryBuffer |
quaternion.decodeFromUint32(value)
Deprecated
Based on GDC talk from Bungie on destiny, compressing quaternions for animation
Kind: instance method of Quaternion
Param | Type |
---|---|
value | number |
quaternion.encodeToUint32() ⇒ number
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
Param | Type | Default |
---|---|---|
array | Array.<number> | |
offset | number | 0 |
quaternion.writeToArray([array], [offset]) ⇒ Array.<number>
Kind: instance method of Quaternion
Param | Type | Default |
---|---|---|
[array] | Array.<number> | |
[offset] | number | 0 |
quaternion.equals(other) ⇒ boolean
Kind: instance method of Quaternion
Param | Type |
---|---|
other | Quaternion |
quaternion.hash() ⇒ number
Kind: instance method of Quaternion
quaternion.roughlyEquals(other, [tolerance]) ⇒ boolean
Kind: instance method of Quaternion
Param | Type |
---|---|
other | Quaternion |
[tolerance] | number |
quaternion.random([random]) ⇒ Quaternion
Based on http://planning.cs.uiuc.edu/node198.html
Kind: instance method of Quaternion
Param | Type |
---|---|
[random] | function |
Quaternion.identity : Quaternion
Kind: static property of Quaternion
Read only: true
Quaternion.random(random) ⇒ Quaternion
Kind: static method of Quaternion
Param | Type | Description |
---|---|---|
random | function | random number generator function |
Quaternion.fromEulerAngles(x, y, z) ⇒ Quaternion
Kind: static method of Quaternion
Param | Type | Description |
---|---|---|
x | number | in radians |
y | number | in radians |
z | number | in radians |
Quaternion.rotateTowards(result, from, to, max_delta)
Behaves similarly to Unity's Quaternion RotateToward
method
Kind: static method of Quaternion
Param | Type | Description |
---|---|---|
result | Quaternion | |
from | Quaternion | |
to | Quaternion | |
max_delta | number | in radians |