Murl Engine Lua Addon API  Version 1.0 beta
Murl.Math.Quaternion

A quaternion class.


Table members

Enumerations


Component

Enumeration of the components raw data index. The components can be accessed by using the [] operator.

Murl.Math.Quaternion.RThe index to the R component.
Murl.Math.Quaternion.IThe index to the I component.
Murl.Math.Quaternion.JThe index to the J component.
Murl.Math.Quaternion.KThe index to the K component.
Murl.Math.Quaternion.NUM_COMPONENTSThe number of components.

ComponentMask

Enumeration of the components' bit masks

Murl.Math.Quaternion.MASK_NONENo component
Murl.Math.Quaternion.MASK_RR component mask
Murl.Math.Quaternion.MASK_II component mask
Murl.Math.Quaternion.MASK_JJ component mask
Murl.Math.Quaternion.MASK_KK component mask
Murl.Math.Quaternion.MASK_IJKComponent mask for I, J and K (imaginary part)
Murl.Math.Quaternion.MASK_ALLAll components

PredefinedType

Enumeration of the predefined initialization types for constructing a Quaternion(PredefinedType type).

Murl.Math.Quaternion.UNINITIALIZEDCreate an uninitialized instance.
Murl.Math.Quaternion.IDENTITYInitialize with the identity {1, 0, 0, 0}.


Functions


Murl.Math.Quaternion.new()

The default constructor.

Murl.Math.Quaternion new()

Returns
Murl.Math.Quaternion

Murl.Math.Quaternion.new(type)

Constructor to create a quaternion from a predefined type.

Murl.Math.Quaternion new(Murl.Math.Quaternion.PredefinedType type)

Parameters
typeThe predefined type.
Returns
Murl.Math.Quaternion

Murl.Math.Quaternion.new(vr, vi, vj, vk)

Constructor to initialize a quaternion with given component values.

Murl.Math.Quaternion new(Number vr, Number vi, Number vj, Number vk)

Parameters
vrThe r component.
viThe i component.
vjThe j component.
vkThe k component.
Returns
Murl.Math.Quaternion

Murl.Math.Quaternion.new(angle, axis)

Constructor to initialize a quaternion from a given rotation angle and a normalized axis vector.

Murl.Math.Quaternion new(Number angle, Murl.Math.Vector axis)

Parameters
angleThe rotation angle.
axisThe normalized axis vector.
Returns
Murl.Math.Quaternion

Murl.Math.Quaternion.new(m)

Constructor to initialize a quaternion from the rotation component of a given 4x4 matrix.

Murl.Math.Quaternion new(Murl.Math.Matrix m)

Parameters
mThe matrix.
Returns
Murl.Math.Quaternion

Murl.Math.Quaternion.new(v)

Constructor to initialize a quaternion from a given 4-vector containing a normalized rotation axis in its x,y and z components, and a rotation angle in its w component.

Murl.Math.Quaternion new(Murl.Math.Vector v)

Parameters
vThe vector.
Returns
Murl.Math.Quaternion


Methods


Set(vr, vi, vj, vk)

Set all components of the quaternion instance to a set of given component values.

Set(Number vr, Number vi, Number vj, Number vk)

Parameters
vrThe x-component value to set.
viThe y-component value to set.
vjThe z-component value to set.
vkThe w-component value to set.

Set(m)

Set the quaternion from the rotation component of a given 4D matrix.

Set(Murl.Math.Matrix m)

Parameters
mThe input matrix.

Set(q)

Copy the content of a source quaternion to the quaternion instance.

Set(Murl.Math.Quaternion q)

Parameters
qThe quaternion to copy from.

Clear()

Clear all components of the quaternion instance. Set all components to default constructor of data type.

Clear()


InvertSelf()

In-place inversion.

InvertSelf()


AddSelf(q)

In-place addition.

AddSelf(Murl.Math.Quaternion q)

Parameters
qThe quaternion to add.

MultiplySelf(d)

In-place multiplication (scaling).

MultiplySelf(Number d)

Parameters
dThe value to multiply.

MultiplySelf(q)

In-place Quaternion-quaternion multiplication.

MultiplySelf(Murl.Math.Quaternion q)

Parameters
qThe quaternion to multiply.

MultiplySelf(v)

In-place Quaternion-vector multiplication.

MultiplySelf(Murl.Math.Vector v)

Parameters
vThe vector to multiply.

NormalizeSelf()

In-place normalization of the quaternion instance.

NormalizeSelf()


Invert()

Get the inverse of a quaternion. This only works for normalized quaternions.

Murl.Math.Quaternion Invert()

Returns
Murl.Math.Quaternion The inverted quaternion.

Add(q)

Get the addition of a quaternion.

Murl.Math.Quaternion Add(Murl.Math.Quaternion q)

Parameters
qThe quaternion to add.
Returns
Murl.Math.Quaternion The added quaternion.

Multiply(d)

Get the multiplication (scaling).

Murl.Math.Quaternion Multiply(Number d)

Parameters
dThe value to multiply.
Returns
Murl.Math.Quaternion The multiplied quaternion.

Multiply(q)

Get the multiplication with a quaternion.

Murl.Math.Quaternion Multiply(Murl.Math.Quaternion q)

Parameters
qThe quaternion to multiply.
Returns
Murl.Math.Quaternion The multiplied quaternion.

Multiply(v)

Get the multiplication with a vector.

Murl.Math.Quaternion Multiply(Murl.Math.Vector v)

Parameters
vThe vector to multiply.
Returns
Murl.Math.Quaternion The multiplied quaternion.

Normalize()

Get the normalization of the quaternion instance.

Murl.Math.Quaternion Normalize()

Returns
Murl.Math.Quaternion The normalized quaternion.

Interpolate(q, t, spherical)

Interpolate between this instance and a second quaternion. For t=0.0, the result equals the first quaternion, and for t=1.0 the second one.

Murl.Math.Quaternion Interpolate(Murl.Math.Quaternion q, Number t, Boolean spherical)

Parameters
qThe quaternion to interpolate to.
tThe interpolation factor.
sphericalIf true, a spherical interpolation is applied. If false, nterpolation is performed in a linear way.
Returns
Murl.Math.Quaternion The interpolated quaternion.

IsEqual(q)

Check if the quaternion instance is equal to a given second quaternion. Compares all values within the default epsilon range Limits::Epsilon().

Boolean IsEqual(Murl.Math.Quaternion q)

Parameters
qThe quaternion to compare.
Returns
Boolean true if equal to the compared quaternion.

IsEqual(q, epsilon)

Check if the quaternion instance is equal to a given second quaternion. Compares all values within a given epsilon range.

Boolean IsEqual(Murl.Math.Quaternion q, Number epsilon)

Parameters
qThe quaternion to compare.
epsilonThe epsilon to compare.
Returns
Boolean true if equal to the compared quaternion.

ToString()

Get the string representation of the object.

String ToString()

Returns
String The string representation of the object.

GetCount()

Get the number of elements in the object.

Integer GetCount()

Returns
Integer The number of elements in the object.


Metamethods


The length operator

The length operator is denoted by the unary prefix operator #.

Returns
GetCount()

The tostring operator

Converts the object content to a string in a reasonable format.

Returns
ToString()

The array subscript operator.

Get a reference to one of the 4 component values.

Parameters
indexThe component index, see enum Component.
Returns
Number = Murl.Math.Quaternion [Integer index]
Assign
Murl.Math.Quaternion [Integer index] = Number

The addition operator.

Addition operator.

Returns
Murl.Math.Quaternion = Murl.Math.Quaternion + Murl.Math.Quaternion

The multiplication operator.

Multiplication (scaling) operator

Returns
Murl.Math.Quaternion = Murl.Math.Quaternion * Number

The multiplication operator.

Quaternion-quaternion multiplication operator.

Returns
Murl.Math.Quaternion = Murl.Math.Quaternion * Murl.Math.Quaternion

The multiplication operator.

Quaternion-vector multiplication operator.

Returns
Murl.Math.Quaternion = Murl.Math.Quaternion * Murl.Math.Vector

The equal to operator.

Equal to comparison operator. Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Quaternion> class. To compare within an epsilon range use Quaternion::IsEqual().

Returns
Boolean = Murl.Math.Quaternion == Murl.Math.Quaternion


Instance Members


r

The R component.

Returns
Number

i

The I component.

Returns
Number

j

The J component.

Returns
Number

k

The K component.

Returns
Number