A Quaternion object which can be used to represent rotations.

Constructor

@:value({ w : 1, z : 0, y : 0, x : 0 })new(x:Float = 0, y:Float = 0, z:Float = 0, w:Float = 1)

Creates a new Quaternion object.

Parameters:

x

The x value of the quaternion.

y

The y value of the quaternion.

z

The z value of the quaternion.

w

The w value of the quaternion.

Variables

read onlymagnitude:Float

w:Float

The w value of the quaternion.

x:Float

The x value of the quaternion.

y:Float

The y value of the quaternion.

z:Float

The z value of the quaternion.

Methods

clone():Quaternion

Clones the quaternion.

Returns:

An exact duplicate of the current Quaternion.

copyFrom(q:Quaternion):Void

Copies the data from a quaternion into this instance.

Parameters:

q

The quaternion to copy from.

fromAxisAngle(axis:Vector3D, angle:Float):Void

Fills the quaternion object with values representing the given rotation around a vector.

Parameters:

axis

The axis around which to rotate

angle

The angle in radians of the rotation.

fromEulerAngles(ax:Float, ay:Float, az:Float):Void

Fills the quaternion object with values representing the given euler rotation.

Parameters:

ax

The angle in radians of the rotation around the ax axis.

ay

The angle in radians of the rotation around the ay axis.

az

The angle in radians of the rotation around the az axis.

fromMatrix(matrix:Matrix3D):Void

Extracts a quaternion rotation matrix out of a given Matrix3D object.

Parameters:

matrix

The Matrix3D out of which the rotation will be extracted.

lerp(qa:Quaternion, qb:Quaternion, t:Float):Void

Linearly interpolates between two quaternions.

Parameters:

qa

The first quaternion to interpolate.

qb

The second quaternion to interpolate.

t

The interpolation weight, a value between 0 and 1.

multiply(qa:Quaternion, qb:Quaternion):Void

Fills the quaternion object with the result from a multiplication of two quaternion objects.

Parameters:

qa

The first quaternion in the multiplication.

qb

The second quaternion in the multiplication.

@:value({ target : null })multiplyVector(vector:Vector3D, ?target:Quaternion):Quaternion

@:value({ val : 1 })normalize(val:Float = 1):Void

Normalises the quaternion object.

@:value({ target : null })rotatePoint(vector:Vector3D, ?target:Vector3D):Vector3D

Rotates a point.

Parameters:

vector

The Vector3D object to be rotated.

target

An optional Vector3D object that will contain the rotated coordinates. If not provided, a new object will be created.

Returns:

A Vector3D object containing the rotated point.

slerp(qa:Quaternion, qb:Quaternion, t:Float):Void

Spherically interpolates between two quaternions, providing an interpolation between rotations with constant angle change rate.

Parameters:

qa

The first quaternion to interpolate.

qb

The second quaternion to interpolate.

t

The interpolation weight, a value between 0 and 1.

@:value({ target : null })toEulerAngles(?target:Vector3D):Vector3D

Fills a target Vector3D object with the Euler angles that form the rotation represented by this quaternion.

Parameters:

target

An optional Vector3D object to contain the Euler angles. If not provided, a new object is created.

Returns:

The Vector3D containing the Euler angles.

@:value({ target : null })toMatrix3D(?target:Matrix3D):Matrix3D

Converts the quaternion to a Matrix3D object representing an equivalent rotation.

Parameters:

target

An optional Matrix3D container to store the transformation in. If not provided, a new object is created.

Returns:

A Matrix3D object representing an equivalent rotation.

@:value({ exclude4thRow : false })toRawData(target:Vector<Float>, exclude4thRow:Bool = false):Void

Converts the quaternion to a Vector.<Number> matrix representation of a rotation equivalent to this quaternion.

Parameters:

target

The Vector.<Number> to contain the raw matrix data.

exclude4thRow

If true, the last row will be omitted, and a 4x3 matrix will be generated instead of a 4x4.

toString():String

Used to trace the values of a quaternion.

Returns:

A string representation of the quaternion object.