Quaternion class.

Static variables

@:value(0)staticnumCreations:Int = 0

The number of instance creation.

Constructor

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

Creates a new quaternion. The quaternion is identity by default.

Variables

w:Float

The real part of the quaternion.

x:Float

The x-value of the imaginary part of the quaternion.

y:Float

The y-value of the imaginary part of the quaternion.

z:Float

The z-value of the imaginary part of the quaternion.

Methods

inlineadd(q:Quat):Quat

Returns this + v.

inlineaddEq(q:Quat):Quat

Sets this quaternion to this + v and returns this.

inlineclone():Quat

Returns a clone of the quaternion.

inlinecopyFrom(q:Quat):Quat

Copies values from q and returns this.

inlinedot(q:Quat):Float

Returns the dot product of this and q.

inlinefromMat3(m:Mat3):Quat

Sets this quaternion to the representation of the matrix m, and returns this.

The matrix m must be a rotation matrix, that is, must be orthogonalized and have determinant 1.

inlineidentity():Quat

Sets the quaternion to identity quaternion and returns this.

inlineinit(x:Float, y:Float, z:Float, w:Float):Quat

Sets all values at once and returns this.

inlinelength():Float

Returns the length of the quaternion.

inlinelengthSq():Float

Returns the squared length of the quaternion.

inlinenormalize():Quat

Sets this quaternion to the normalized quaternion and returns this.

If the length is zero, this quaternion is set to zero quaternion.

inlinenormalized():Quat

Returns the normalized quaternion.

If the length is zero, zero quaterinon is returned.

inlinescale(s:Float):Quat

Returns this * s.

inlinescaleEq(s:Float):Quat

Sets this quaternion to this * s and returns this.

setArc(v1:Vec3, v2:Vec3):Quat

Sets this quaternion to the quaternion representing the shortest arc rotation from v1 to v2, and return this.

slerp(q:Quat, t:Float):Quat

Returns the spherical linear interpolation between two quaternions this and q with interpolation paraeter t. Both quaternions this and q must be normalized.

inlinesub(q:Quat):Quat

Returns this - v.

inlinesubEq(q:Quat):Quat

Sets this quaternion to this - v and returns this.

inlinetoMat3():Mat3

Returns a rotation matrix which represents this quaternion.

inlinetoString():String

Returns the string representation of the quaternion.