Constructor
new Quaternion(x, y, z, w)
Creates a new quaternion.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
x |
Number | 0 | The x component. |
y |
Number | 0 | The y component. |
z |
Number | 0 | The z component. |
w |
Number | 1 | The w component. |
- Source:
Members
(static) identity
An identity quaternion.
- Source:
Methods
clone() → {Quaternion}
Creates a clone of the quaternion.
- Source:
Returns:
The cloned quaternion.
- Type
- Quaternion
conjugate() → {Quaternion}
Sets the quaternion to its conjugate.
- Source:
Returns:
The quaternion.
- Type
- Quaternion
conjugateQuaternion(q) → {Quaternion}
Sets the quaternion to the conjugate of another quaternion.
Parameters:
Name | Type | Description |
---|---|---|
q |
Quaternion | The quaternion to calculate the conjugate. |
- Source:
Returns:
The quaternion.
- Type
- Quaternion
copy(q) → {Quaternion}
Copies the components of another quaternion.
Parameters:
Name | Type | Description |
---|---|---|
q |
Quaternion | The quaternion to copy the components from. |
- Source:
Returns:
The quaternion.
- Type
- Quaternion
dot(q) → {Number}
Calculates the dot product with another quaternion.
Parameters:
Name | Type | Description |
---|---|---|
q |
Quaternion | The quaternion to calculate the dot product with. |
- Source:
Returns:
The dot product between the quaternions.
- Type
- Number
invert() → {Quaternion}
Sets the quaternion to its inverse.
- Source:
Returns:
The quaternion.
- Type
- Quaternion
invertQuaternion(q)
Sets the quaternion to the inverse of another quaternion.
Parameters:
Name | Type | Description |
---|---|---|
q |
Quaternion | The quaternion to calculate the inverse. |
- Source:
length() → {Number}
Calculates the length of the quaternion.
- Source:
Returns:
The length of the quaternion.
- Type
- Number
lengthSquared() → {Number}
Calculates the squared length of the quaternion.
- Source:
Returns:
The squared length of the quaternion.
- Type
- Number
multiplyQuaternions(q, r) → {Quaternion}
Sets the quaternion to the product of other two quaternions.
Parameters:
Name | Type | Description |
---|---|---|
q |
Quaternion | The first quaternion. |
r |
Quaternion | The second quaternion. |
- Source:
Returns:
The quaternion.
- Type
- Quaternion
normalize() → {Quaternion}
Normalizes the quaternion.
- Source:
Returns:
The quaternion.
- Type
- Quaternion
set(x, y, z, w) → {Quaternion}
Sets the components of the quaternion.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | The x component. |
y |
Number | The y component. |
z |
Number | The z component. |
w |
Number | The w component. |
- Source:
Returns:
The quaternion.
- Type
- Quaternion
setAxisAngle(axis, angle) → {Quaternion}
Sets the quaternion to a rotation.
Parameters:
Name | Type | Description |
---|---|---|
axis |
Vector3 | The axis to rotate around. |
angle |
Number | The angle to rotate. |
- Source:
Returns:
The quaternion.
- Type
- Quaternion
setIdentity() → {Quaternion}
Sets the components of the quaternion to the identity.
- Source:
Returns:
The quaternion.
- Type
- Quaternion