TruWorlds

Quaternion

Represents a quaternion for 3D rotations.

Fields

X float

The X component of the quaternion.

Y float

The Y component of the quaternion.

Z float

The Z component of the quaternion.

W float

The W component of the quaternion.

Functions

Normalized() Returns Quaternion

Returns a normalized version of the quaternion.

Returns: >The normalized quaternion.

Xform(v: Vector3) Returns Vector3

Transforms a vector by the quaternion rotation.

v
The vector to transform.

Returns: The transformed vector.

Slerp(a: Quaternion, b: Quaternion, t: float) Returns Quaternion

Spherically interpolates between two quaternions.

a
The starting quaternion.
b
The ending quaternion.
t
The interpolation factor (0 to 1).

Returns: The interpolated quaternion.

Slerp(b: Quaternion, t: float) Returns Quaternion

Spherically interpolates between this quaternion and another quaternion.

b
The ending quaternion.
t
The interpolation factor (0 to 1).

Returns: The interpolated quaternion.

ToEulerDegrees() Returns Vector3

Converts the quaternion to Euler angles in degrees (in Yxz order).

Returns: The Euler angles in degrees.

FromEulerDegrees(euler: Vector3) Returns Quaternion

Creates a quaternion from Euler angles in degrees. (in Yxz order).

euler
The Euler angles in degrees.

Returns: The resulting quaternion.

FromAxisAngle(axis: Vector3, angle: float) Returns Quaternion

Creates a quaternion from an axis and angle (in radians).

axis
The rotation axis (should be normalized).
angle
The rotation angle in radians.

Returns: The resulting quaternion.

RotateByAxis(axis: Vector3, angle: float) Returns Quaternion

Rotates this quaternion by an additional rotation around the specified axis.

axis
The rotation axis (should be normalized).
angle
The rotation angle in radians.

Returns: The rotated quaternion.

Inverse() Returns Quaternion

Returns the inverse of the quaternion, which represents the opposite rotation.

Returns: The inverse quaternion.