Class: Quaternion
Quaternions are used to represent rotations.
Constructors
Properties
Accessors
Methods
- identity
- quaternionToMatrix
- set
- divide
- multiply
- multiplyVector
- fromAxisAngle
- toAxisAngle
- slerp
- lerp
- fromEulerAngles
- setFromRotationMatrix
- getEulerAngles
- normalize
- toString
- fromMatrix
- inverse
- clone
- transformVector
- copyFrom
- mul
- serialize
Constructors
constructor
• new Quaternion(x?
, y?
, z?
, w?
): Quaternion
Create a new quaternion object
Parameters
Name | Type | Default value | Description |
---|---|---|---|
x | number | 0 | The X component of a quaternion. |
y | number | 0 | The Y component of a quaternion. |
z | number | 0 | The Z component of a quaternion. |
w | number | 1 | The W component of a quaternion. |
Returns
Defined in
Properties
HELP_0
▪ Static
HELP_0: Quaternion
Defined in
HELP_1
▪ Static
HELP_1: Quaternion
Defined in
HELP_2
▪ Static
HELP_2: Quaternion
Defined in
_zero
▪ Static
_zero: Quaternion
Defined in
CALCULATION_QUATERNION
▪ Static
CALCULATION_QUATERNION: Quaternion
Defined in
Accessors
magnitude
• get
magnitude(): number
Returns
number
Defined in
Methods
identity
▸ identity(): Quaternion
Identity quaternion
Returns
Defined in
quaternionToMatrix
▸ quaternionToMatrix(q
, m
): void
Converts quaternions to matrices
Parameters
Name | Type | Description |
---|---|---|
q | Quaternion | Quaternion |
m | any | Matrix |
Returns
void
Defined in
set
▸ set(x?
, y?
, z?
, w?
): Quaternion
Set the x, y, z, and w components of the existing quaternions.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
x | number | 0 | The X component of a quaternion. |
y | number | 0 | The Y component of a quaternion. |
z | number | 0 | The Z component of a quaternion. |
w | number | 1 | The W component of a quaternion. |
Returns
Defined in
divide
▸ divide(v
): Quaternion
Parameters
Name | Type |
---|---|
v | any |
Returns
Defined in
multiply
▸ multiply(qa
, qb
): void
Multiply two quaternions
Parameters
Name | Type | Description |
---|---|---|
qa | Quaternion | Quaternion 1 |
qb | Quaternion | Quaternion 2 |
Returns
void
Defined in
multiplyVector
▸ multiplyVector(vector
, target?
): Quaternion
Parameters
Name | Type | Default value |
---|---|---|
vector | Vector3 | undefined |
target | Quaternion | null |
Returns
Defined in
fromAxisAngle
▸ fromAxisAngle(axis
, angle
): void
Set the quaternion with a given rotation of the axis and Angle.
Parameters
Name | Type | Description |
---|---|---|
axis | Vector3 | axis |
angle | number | angle |
Returns
void
Defined in
toAxisAngle
▸ toAxisAngle(axis
): number
Turn quaternions into angles
Parameters
Name | Type | Description |
---|---|---|
axis | Vector3 | axis |
Returns
number
Defined in
slerp
▸ slerp(qa
, qb
, t
): void
Spherically interpolates between two quaternions, providing an interpolation between rotations with constant angle change rate.
Parameters
Name | Type | Description |
---|---|---|
qa | Quaternion | The first quaternion to interpolate. |
qb | Quaternion | The second quaternion to interpolate. |
t | number | The interpolation weight, a value between 0 and 1. |
Returns
void
Defined in
lerp
▸ lerp(qa
, qb
, t
): void
Linearly interpolates between two quaternions.
Parameters
Name | Type | Description |
---|---|---|
qa | Quaternion | The first quaternion to interpolate. |
qb | Quaternion | The second quaternion to interpolate. |
t | number | The interpolation weight, a value between 0 and 1. |
Returns
void
Defined in
fromEulerAngles
▸ fromEulerAngles(ax
, ay
, az
): Quaternion
Fills the quaternion object with values representing the given euler rotation.
Parameters
Name | Type | Description |
---|---|---|
ax | number | The angle in radians of the rotation around the ax axis. |
ay | number | The angle in radians of the rotation around the ay axis. |
az | number | The angle in radians of the rotation around the az axis. |
Returns
Defined in
setFromRotationMatrix
▸ setFromRotationMatrix(m
): Quaternion
Sets the current quaternion from the rotation matrix
Parameters
Name | Type |
---|---|
m | Object |
m.rawData | Float32Array |
Returns
Defined in
getEulerAngles
▸ getEulerAngles(eulers?
): Vector3
Get the Euler Angle
Parameters
Name | Type |
---|---|
eulers? | Vector3 |
Returns
Defined in
normalize
▸ normalize(val?
): void
The normalize of the quaternion. Convert this quaternion to a normalize coefficient.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
val | number | 1 | normalize coefficient, which is 1 by default |
Returns
void
Defined in
toString
▸ toString(): string
Returns the value of a quaternion as a string
Returns
string
Defined in
fromMatrix
▸ fromMatrix(matrix
): void
Extracts a quaternion rotation matrix out of a given Matrix3D object.
Parameters
Name | Type | Description |
---|---|---|
matrix | any | The Matrix3D out of which the rotation will be extracted. |
Returns
void
Defined in
inverse
▸ inverse(target?
): Quaternion
Returns a quaternion that inverts the current quaternion
Parameters
Name | Type | Default value | Description |
---|---|---|---|
target | Quaternion | null | The default parameter is null. If the current parameter is null, a new quaternion object is returned |
Returns
Quaternion Result
Defined in
clone
▸ clone(): Quaternion
Clones the quaternion.
Returns
An exact duplicate of the current Quaternion.
Defined in
transformVector
▸ transformVector(vector
, target?
): Vector3
Rotates a point.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
vector | Vector3 | undefined | The Vector3D object to be rotated. |
target | Vector3 | null | An optional Vector3D object that will contain the rotated coordinates. If not provided, a new object will be created. |
Returns
A Vector3D object containing the rotated point.
Defined in
copyFrom
▸ copyFrom(q
): this
Copies the data from a quaternion into this instance.
Parameters
Name | Type | Description |
---|---|---|
q | Vector3 | Quaternion | The quaternion to copy from. |
Returns
this
Defined in
mul
▸ mul(lhs
, rhs
, target?
): Quaternion
from untiy API op
Parameters
Name | Type |
---|---|
lhs | Quaternion |
rhs | Quaternion |
target? | Quaternion |
Returns
Defined in
serialize
▸ serialize(value
): Quaternion
Parameters
Name | Type |
---|---|
value | Quaternion |