Quaternion

class Quaternion : Vector4

Represents a quaternion for 3D rotations.

Quaternions are used to represent rotations in 3D space without the singularities of Euler angles. This class extends Vector4 where x, y, z represent the vector part and w represents the scalar part.

The quaternion is typically normalized (unit length) for rotation representation. This class is designed for compatibility with AR frameworks like ARCore.

Constructors

Quaternion
Link copied to clipboard
fun Quaternion()

Creates an identity quaternion (no rotation).

Quaternion
Link copied to clipboard
fun Quaternion(data: Quaternion)

Creates a copy of another quaternion.

Quaternion
Link copied to clipboard
fun Quaternion(x: Float, y: Float, z: Float, w: Float)

Creates a quaternion with specific component values.

Types

Companion
Link copied to clipboard
object Companion

Functions

describeContents
Link copied to clipboard
open override fun describeContents(): Int
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
get
Link copied to clipboard
fun get(index: Int): Float

Gets the component at the specified index.

set
Link copied to clipboard
fun set(data: Quaternion)
fun set(data: Vector4)

Sets all components from another Vector4.

fun set(index: Int, value: Float)

Sets the component at the specified index.

fun set(x: Float, y: Float, z: Float, w: Float)

Sets all components to the specified values.

toString
Link copied to clipboard
open override fun toString(): String
writeToParcel
Link copied to clipboard
open override fun writeToParcel(parcel: Parcel, flags: Int)

Properties

identity
Link copied to clipboard
val identity: Quaternion

Returns the identity quaternion (0, 0, 0, 1) representing no rotation.

normalize
Link copied to clipboard
val normalize: Quaternion

Returns a normalized version of this quaternion.

w
Link copied to clipboard
var w: Float

The w component of the vector (typically 1.0 for positions, 0.0 for directions)

x
Link copied to clipboard
var x: Float

The x component of the vector

y
Link copied to clipboard
var y: Float

The y component of the vector

z
Link copied to clipboard
var z: Float

The z component of the vector