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