Constructor
new Quaternion(xopt, yopt, zopt, wopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | Number | <optional> | 0 | x coordinate |
y | Number | <optional> | 0 | y coordinate |
z | Number | <optional> | 0 | z coordinate |
w | Number | <optional> | 1 | w coordinate |
Members
w :Number
Type:
- Number
w :Number
Type:
- Number
x :Number
Type:
- Number
x :Number
Type:
- Number
y :Number
Type:
- Number
y :Number
Type:
- Number
z :Number
Type:
- Number
z :Number
Type:
- Number
Methods
clone() → {t3d.Quaternion}
Creates a new Quaternion with identical x, y, z and w properties to this one.
Returns:
- Type:
- t3d.
Quaternion
conjugate() → {t3d.Quaternion}
Returns the rotational conjugate of this quaternion. The conjugate of a quaternion represents the same rotation in the opposite direction about the rotational axis.
Returns:
- Type:
- t3d.
Quaternion
copy(quaternion) → {t3d.Quaternion}
Copies the x, y, z and w properties of q into this quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion | t3d. |
Returns:
- Type:
- t3d.
Quaternion
dot(v) → {t3d.Quaternion}
Calculates the dot product of quaternions v and this one.
Parameters:
Name | Type | Description |
---|---|---|
v | t3d. |
Returns:
- Type:
- t3d.
Quaternion
fromArray(array, offsetopt, denormalizeopt) → {t3d.Quaternion}
Sets this quaternion's x, y, z and w properties from an array.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<Number> | array of format (x, y, z, w) used to construct the quaternion. | ||
offset | Number | <optional> | 0 | an offset into the array. |
denormalize | Boolean | <optional> | false | if true, denormalize the values, and array should be a typed array. |
Returns:
- Type:
- t3d.
Quaternion
length() → {Number}
Computes the Euclidean length (straight-line length) of this quaternion, considered as a 4 dimensional vector.
Returns:
- Type:
- Number
lerpQuaternions(q1, q2, ratio) → {t3d.Quaternion}
Linearly interpolates between two quaternions.
Parameters:
Name | Type | Description |
---|---|---|
q1 | t3d. | |
q2 | t3d. | |
ratio | Number |
Returns:
- Type:
- t3d.
Quaternion
multiply(q) → {t3d.Quaternion}
Multiplies this quaternion by q.
Parameters:
Name | Type | Description |
---|---|---|
q | t3d. |
Returns:
- Type:
- t3d.
Quaternion
multiplyQuaternions(a, b) → {t3d.Quaternion}
Sets this quaternion to a x b.
Parameters:
Name | Type | Description |
---|---|---|
a | t3d. | |
b | t3d. |
Returns:
- Type:
- t3d.
Quaternion
normalize() → {t3d.Quaternion}
Normalizes this quaternion - that is, calculated the quaternion that performs the same rotation as this one, but has length equal to 1.
Returns:
- Type:
- t3d.
Quaternion
onChange(callback) → {t3d.Quaternion}
Parameters:
Name | Type | Description |
---|---|---|
callback | function | When the Quaternion angle value changes, the callback method is triggered |
Returns:
- Type:
- t3d.
Quaternion
premultiply(q) → {t3d.Quaternion}
Pre-multiplies this quaternion by q.
Parameters:
Name | Type | Description |
---|---|---|
q | t3d. |
Returns:
- Type:
- t3d.
Quaternion
set(x, y, z, w) → {t3d.Quaternion}
Sets x, y, z, w properties of this quaternion.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
x | Number | 0 | |
y | Number | 0 | |
z | Number | 0 | |
w | Number | 1 |
Returns:
- Type:
- t3d.
Quaternion
setFromAxisAngle(axis, angle) → {t3d.Quaternion}
Set quaternion from axis angle
Parameters:
Name | Type | Description |
---|---|---|
axis | t3d. | |
angle | Number |
Returns:
- Type:
- t3d.
Quaternion
setFromEuler(euler, updateopt) → {t3d.Quaternion}
Sets this quaternion from the rotation specified by Euler angle.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
euler | t3d. | |||
update | Boolean | <optional> | true | Whether to notify quaternion angle has changed |
Returns:
- Type:
- t3d.
Quaternion
setFromRotationMatrix(m) → {t3d.Quaternion}
Sets this quaternion from rotation component of m.
Parameters:
Name | Type | Description |
---|---|---|
m | t3d. |
Returns:
- Type:
- t3d.
Quaternion
setFromUnitVectors(vFrom, vTo) → {t3d.Quaternion}
vFrom and vTo are assumed to be normalized.
Parameters:
Name | Type | Description |
---|---|---|
vFrom | t3d. | |
vTo | t3d. |
Returns:
- Type:
- t3d.
Quaternion
slerpQuaternions(q1, q2, ratio) → {t3d.Quaternion}
Spherically interpolates between two quaternions providing an interpolation between rotations with constant angle change rate.
Parameters:
Name | Type | Description |
---|---|---|
q1 | t3d. | |
q2 | t3d. | |
ratio | Number |
Returns:
- Type:
- t3d.
Quaternion
toArray(arrayopt, offsetopt, normalizeopt) → {t3d.Quaternion}
Returns the numerical elements of this quaternion in an array of format [x, y, z, w].
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<Number> | <optional> | An array to store the quaternion. If not specified, a new array will be created. | |
offset | Number | <optional> | 0 | An offset into the array. |
normalize | Boolean | <optional> | false | if true, normalize the values, and array should be a typed array. |
Returns:
- Type:
- t3d.
Quaternion
toMatrix4(target) → {t3d.Matrix4}
Convert the current quaternion to a matrix4
Parameters:
Name | Type | Description |
---|---|---|
target | t3d. |
Returns:
- Type:
- t3d.
Matrix4
(static) multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) → {Array.<Number>}
Multipley quaternions, but operates directly on flat arrays of numbers.
Parameters:
Name | Type | Description |
---|---|---|
dst | Array.<Number> | The output array. |
dstOffset | Number | An offset into the output array. |
src0 | Array.<Number> | The source array of the starting quaternion. |
srcOffset0 | Number | An offset into the array src0. |
src1 | Array.<Number> | The source array of the target quatnerion. |
srcOffset1 | Number | An offset into the array src1. |
Returns:
- Type:
- Array.<Number>
(static) slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t)
Slerp method, operates directly on flat arrays of numbers.
Parameters:
Name | Type | Description |
---|---|---|
dst | Array.<Number> | The output array. |
dstOffset | Number | An offset into the output array. |
src0 | Array.<Number> | The source array of the starting quaternion. |
srcOffset0 | Number | An offset into the array src0. |
src1 | Array.<Number> | The source array of the target quatnerion. |
srcOffset1 | Number | An offset into the array src1. |
t | Number | Normalized interpolation factor (between 0 and 1). |