Skip to content

Quaternion

Adrien GIVRY edited this page Sep 26, 2020 · 3 revisions

Description

Mathematic representation of a Quaternion with float precision

Variables

Name Type Description
x number X component of the Quaternion
y number Y component of the Quaternion
z number Z component of the Quaternion
w number W component of the Quaternion

Constructors

Name Input Output Description
new Quaternion Default Quaternion constructor (Creates an identity quaternion with 1 as w)
new number: real
Quaternion Creates an identity quaternion with a defined real value
new number: x
number: y
number: z
number: w
Quaternion Creates a quaternion from a set of 4 floats (x, y, z, w)

Functions

Name Input Output Description
IsIdentity Quaternion: instance
boolean Returns true if the quaternion is Identity (x, y and z components are 0)
IsPure Quaternion: instance
boolean Returns true if the quaternion is pure (w is 0)
IsNormalized Quaternion: instance
boolean Returns true if the quaternion is nornalized
Dot Quaternion: a
Quaternion: b
number Calculates the dot product between two quaternions
Normalize Quaternion: instance
Quaternion Returns the normalized version of the given quaternion
Length Quaternion: instance
number Returns the length of the given quaternion
LengthSquare Quaternion: instance
number Returns the squared length of the given quaternion. This function is faster than Quaternion.Length
GetAngle Quaternion: instance
number Returns the angle of the given quaternion
GetRotationAxis Quaternion: instance
Vector3 Returns the rotation axis of the given quaternion
Inverse Quaternion: instance
Quaternion Returns the inverse of the quaternion
Conjugate Quaternion: instance
Quaternion Returns the conjugate of the quaternion
Square Quaternion: instance
Quaternion Returns the squared version of this quaternion
GetAxisAndAngle Quaternion: instance
Vector3: axis
number: angle
Returns the axis and the angle of the given quaternion
AngularDistance Quaternion: a
Quaternion: b
number Returns the angle between two quaternions
Lerp Quaternion: a
Quaternion: b
number: t
Quaternion Returns the linear interpolation of two quaternions based on the given interpolation coefficient
Slerp Quaternion: a
Quaternion: b
number: t
Quaternion Returns the spherical linear interpolation of two quaternions based on the given interpolation coefficient
Nlerp Quaternion: a
Quaternion: b
number: t
Quaternion Returns the nornmalized linear interpolation of two quaternions based on the given interpolation coefficient
RotatePoint Vector3: point
Quaternion: quaternion
Vector3: pivot
Vector3 Rotates a point around a pivot using a quaternion
EulerAngles Quaternion: instance
Vector Returns euler axis angles (In degrees)
ToMatrix3 Quaternion: instance
Matrix3 Returns a rotation matrix (3x3) out of the given quaternion
ToMatrix4 Quaternion: instance
Matrix4 Returns a rotation matrix (4x4) out of the given quaternion

Operators

Operation Description
Quaternion + Quaternion Adds two Quaternion
Quaternion - Quaternion Substracts two Quaternion
Quaternion * number Multiplies each components of a Quaternion by a number
Quaternion * Vector3 Multiplies a Quaternion by a Vector3
Quaternion * Matrix3 Multiplies a Quaternion by a Matrix3
Quaternion / number Divides each component of a Quaternion by a number
to_string(Quaternion) Converts a Quaternion to a string
Clone this wiki locally