Skip to content
Select language:English

MCL 1.3.5

class Quatd(x: Double, y: Double, z: Double, w: Double)

Represents a quaternion using double-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: Double, y: Double, z: Double, w: Double)

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: Double

W component.

val x: Double

X component.

val y: Double

Y component.

val z: Double

Z component.

Functions

operator fun div(scalar: Double): Quatd

Divides this quaternion by a scalar.

fun inverse(): Quatd

Returns the inverse of the quaternion.

operator fun minus(other: Quatd): Quatd

Subtracts one quaternion from another.

operator fun plus(other: Quatd): Quatd

Adds two quaternions.

fun rotate(vector: Vec3d): Vec3d

Rotates a 3D vector using this quaternion.

operator fun times(other: Quatd): Quatd

Quaternion–Quaternion multiplication.

operator fun times(v: Vec3d): Vec3d

Applies this quaternion to a 3D vector.

operator fun times(scalar: Double): Quatd

Multiplies this quaternion by a scalar.

Converts this quaternion to axis-angle representation.

fun toFloat(): Quatf

Converts this quaternion to a Quatf object.

open override fun toString(): String

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