Quaternion
Implementation of a quaternion. Quaternions are used to represent rotations.
Constructors
constructor
Parameters
- x: number
- y: number
- z: number
- w: number
Returns Quaternion
Properties
is Quaternion
Check the type whether it belongs to Matrix3. This value should not be changed by user.
Accessors
x
- get x(): number
Returns number
- set x(value: number): void
Parameters
- value: number
Returns void
y
- get y(): number
Returns number
- set y(value: number): void
Parameters
- value: number
Returns void
z
- get z(): number
Returns number
- set z(value: number): void
Parameters
- value: number
Returns void
w
- get w(): number
Returns number
- set w(value: number): void
Parameters
- value: number
Returns void
Methods
on Change Callback
The function will be called when _x| x, _y| y _z| z and _w| w is changed.
Returns void
Staticslerp
Handles the spherical linear interpolation between quaternions. t represents the amount of rotation between this quaternion (where t is 0) and qb (where t is 1). This quaternion is set to the result. Also see the static version of the
slerpbelow.// rotate a mesh towards a target quaternion mesh.quaternion.slerp( endQuaternion, 0.01 );
Parameters
- qa: Quaternion
- qb: Quaternion
The other quaternion rotation.
- qm: Quaternion
- t: number
interpolation factor in the closed interval [0, 1].
Returns Quaternion
Staticslerp Flat
- slerpFlat(
dst: number[],
dstOffset: number,
src0: number[],
srcOffset0: number,
src1: number[],
srcOffset1: number,
t: number,
): voidLike the static slerp method above, but operates directly on flat arrays of numbers.
Parameters
- dst: number[]
The output array.
- dstOffset: number
An offset into the output array.
- src0: number[]
The source array of the starting quaternion.
- srcOffset0: number
An offset into the array
src0. - src1: number[]
The source array of the target quaternions.
- srcOffset1: number
An offset into the array
src1. - t: number
Normalized interpolation factor (between 0 and 1).
Returns void
- dst: number[]
set
Parameters
- x: number
- y: number
- z: number
- w: number
Returns Quaternion
clone
Returns Quaternion
copy
Parameters
- quaternion: Quaternion
Returns Quaternion
set From Euler
Sets this quaternion from the rotation specified by Euler angle.
Parameters
- euler: Euler
- update: boolean
Returns Quaternion
set From Axis Angle
Sets this quaternion from rotation specified by axis and Float| angle. Adapted from the method here.
Parameters
- axis: Vector3
- angle: number
is in radians.
Returns Quaternion
set From Rotation Matrix
Parameters
- m: Matrix4
a Matrix4 of which the upper 3x3 of matrix is a pure rotation matrix.
Returns Quaternion
- m: Matrix4
set From Unit Vectors
conjugate
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 Quaternion
dot
length Sq
Computes the squared Euclidean length (straight-line length) of this quaternion, considered as a 4 dimensional vector. This can be useful if you are comparing the lengths of two quaternions, as this is a slightly more efficient calculation than length| length().
Returns number
length
Computes the Euclidean length (straight-line length) of this quaternion, considered as a 4 dimensional vector.
Returns number
normalize
Normalizes this quaternion - that is, calculated the quaternion that performs the same rotation as this one, but has length| length equal to
1.Returns Quaternion
multiply
premultiply
multiply Quaternions
Parameters
- a: Quaternion
- b: Quaternion
Returns Quaternion
slerp
Handles the spherical linear interpolation between quaternions. t represents the amount of rotation between this quaternion (where t is 0) and qb (where t is 1). This quaternion is set to the result. Also see the static version of the method slerp.
// rotate a mesh towards a target quaternion mesh.quaternion.slerp( endQuaternion, 0.01 );
Parameters
- qb: Quaternion
The other quaternion rotation.
- t: number
interpolation factor in the closed interval [0, 1].
Returns Quaternion
- qb: Quaternion
equals
from Array
Parameters
- array: ArrayLike<number>
array of format (x, y, z, w) used to construct the quaternion.
- offset: number
(optional) an offset into the array.
Returns Quaternion
- array: ArrayLike<number>
to Array
Returns the numerical elements of this quaternion in an array of format [x, y, z, w].
Parameters
- array: number[]
An optional array to store the quaternion. If not specified, a new array will be created.
- offset: number
(optional) if specified, the result will be copied into this array.
Returns number[]
- array: number[]
Implementation of a quaternion. Quaternions are used to represent rotations.