a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Client / Quaternion
Represents a 3D rotation using a quaternion. A quaternion is a mathematical concept used to represent rotations in three-dimensional space. It consists of four components: x, y, z (vector part) and w (scalar part).
new Quaternion(
x
,y
,z
,w
):Quaternion
Creates a new Quaternion instance.
• x: number
{number} - The x component of the quaternion.
• y: number
{number} - The y component of the quaternion.
• z: number
{number} - The z component of the quaternion.
• w: number
{number} - The w (scalar) component of the quaternion.
w:
number
{number} - The w (scalar) component of the quaternion.
x:
number
{number} - The x component of the quaternion.
y:
number
{number} - The y component of the quaternion.
z:
number
{number} - The z component of the quaternion.
get
Length():number
Gets the length (magnitude) of the quaternion.
number
The magnitude of the quaternion.
get
normalize():Quaternion
Gets the normalized quaternion (unit quaternion). Normalization makes the magnitude of the quaternion equal to 1.
A new quaternion that is the normalized version of this quaternion.
conjugate():
Quaternion
Returns the conjugate of this quaternion. The conjugate of a quaternion is obtained by negating its vector part.
A new quaternion representing the conjugate of this quaternion.
client/utils/Quaternion.ts:136
dot(
q
):number
Computes the dot product between this quaternion and another quaternion. The dot product is a measure of the angle between two quaternions.
• q: Quaternion
{Quaternion} - The other quaternion.
number
The dot product of the two quaternions.
client/utils/Quaternion.ts:164
equals(
other
,tolerance
):boolean
Checks if this quaternion is equal to another quaternion within a certain tolerance.
• other: Quaternion
{Quaternion} - The quaternion to compare with.
• tolerance: number
= 1e-6
The tolerance within which the two quaternions are considered equal. Default is 1e-6.
boolean
True if the quaternions are equal within the given tolerance, false otherwise.
inverse():
Quaternion
Returns the inverse of this quaternion. The inverse is calculated by conjugating the quaternion and dividing by the square of its magnitude.
A new quaternion representing the inverse of this quaternion.
client/utils/Quaternion.ts:146
multiply(
other
):Quaternion
Multiplies this quaternion by another quaternion. The result is a new quaternion representing the combined rotation.
• other: Quaternion
{Quaternion} - The quaternion to multiply with.
A new quaternion representing the product of the two quaternions.
client/utils/Quaternion.ts:121
slerp(
q1
,t
):Quaternion
Performs spherical linear interpolation (SLERP) between this quaternion and another quaternion. SLERP is used to interpolate between two quaternions with constant angular velocity.
• q1: Quaternion
{Quaternion} - The quaternion to interpolate towards.
• t: number
{number} - The interpolation factor, ranging from 0 to 1.
A new quaternion representing the interpolated quaternion.
client/utils/Quaternion.ts:177
toArray(): [
number
,number
,number
,number
]
Converts the quaternion to an array of numbers [x, y, z, w].
[number
, number
, number
, number
]
An array containing the quaternion components.
toEulerAngles():
EulerAngles
Converts the quaternion to Euler angles (roll, pitch, yaw). Euler angles are a way to represent 3D rotations using three angles.
An object containing the roll, pitch, and yaw angles in radians.
client/utils/Quaternion.ts:217
toJson():
object
Converts the quaternion to a JSON object.
object
A JSON object with x, y, z, and w properties.
w:
number
x:
number
y:
number
z:
number
client/utils/Quaternion.ts:104
static
angleBetween(q1
,q2
):number
Calculates the angle between two quaternions.
• q1: Quaternion
{Quaternion} - The first quaternion.
• q2: Quaternion
{Quaternion} - The second quaternion.
number
The angle in radians between the two quaternions.
client/utils/Quaternion.ts:295
static
applyToEntity(entity
,quaternion
):void
Applies a quaternion rotation to an entity.
• entity: number
The entity to apply the quaternion to.
• quaternion: Quaternion
The quaternion representing the rotation to apply.
void
client/utils/Quaternion.ts:317
static
fromEntity(entity
):Quaternion
Creates a quaternion from an entity’s rotation.
• entity: number
The entity whose quaternion is to be retrieved.
A new quaternion representing the entity’s rotation.
client/utils/Quaternion.ts:306
static
fromEulerAngles(eulerAngles
):Quaternion
Creates a quaternion from Euler angles (roll, pitch, yaw).
• eulerAngles: EulerAngles
{EulerAngles} - An object containing the roll, pitch, and yaw angles in radians.
A new quaternion representing the rotation.
client/utils/Quaternion.ts:244
static
identity():Quaternion
Returns the identity quaternion (no rotation).
A new quaternion representing no rotation.
client/utils/Quaternion.ts:283
static
lerp(q1
,q2
,t
):Quaternion
Performs linear interpolation (LERP) between two quaternions.
• q1: Quaternion
{Quaternion} - The starting quaternion.
• q2: Quaternion
{Quaternion} - The ending quaternion.
• t: number
{number} - The interpolation factor (0 to 1).
A new quaternion that is the result of the interpolation.