Skip to content
Select language:English

MCL 1.3.5

class Quatf(x: Float, y: Float, z: Float, w: Float)

Represents a quaternion using single-precision floating-point components.

A quaternion is defined as: q = w + xi + yj + zk where (x, y, z) is the imaginary (vector) part and w is the real (scalar) part.

This implementation does NOT automatically normalize instances. If the quaternion represents a rotation, it is recommended to use a unit quaternion.

Parameters

x

X component of the imaginary part.

y

Y component of the imaginary part.

z

Z component of the imaginary part.

w

Scalar (real) component.

Constructors

constructor(x: Float, y: Float, z: Float, w: Float)

Types

Properties

Returns the conjugate of the quaternion.

Computes the heading (yaw) angle in radians.

Returns the magnitude (norm) of the quaternion.

Returns the squared magnitude of the quaternion.

Returns a normalized copy of this quaternion.

Array of components.

val w: Float

W component.

val x: Float

X component.

val y: Float

Y component.

val z: Float

Z component.

Functions

operator fun div(scalar: Float): Quatf

Divides this quaternion by a scalar.

fun inverse(): Quatf

Returns the inverse of the quaternion.

operator fun minus(other: Quatf): Quatf

Subtracts one quaternion from another.

operator fun plus(other: Quatf): Quatf

Adds two quaternions.

fun rotate(vector: Vec3f): Vec3f

Rotates a 3D vector using this quaternion.

operator fun times(other: Quatf): Quatf

Quaternion–Quaternion multiplication.

operator fun times(v: Vec3f): Vec3f

Applies this quaternion to a 3D vector.

operator fun times(scalar: Float): Quatf

Multiplies this quaternion by a scalar.

Converts this quaternion to axis-angle representation.

Converts this quaternion to a Quatd object.

open override fun toString(): String

Returns a JSON-like string representation of the quaternion with components formatted to three decimal digits.