3x3 Matrix class.

Note that columns and rows are 0-indexed.

Static variables

@:value(0)staticnumCreations:Int = 0

The number of instance creation.

Constructor

@:value({ e22 : 1, e21 : 0, e20 : 0, e12 : 0, e11 : 1, e10 : 0, e02 : 0, e01 : 0, e00 : 1 })inlinenew(e00:Float = 1, e01:Float = 0, e02:Float = 0, e10:Float = 0, e11:Float = 1, e12:Float = 0, e20:Float = 0, e21:Float = 0, e22:Float = 1)

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

Variables

e00:Float

The element at row 0 column 0.

e01:Float

The element at row 0 column 1.

e02:Float

The element at row 0 column 2.

e10:Float

The element at row 1 column 0.

e11:Float

The element at row 1 column 1.

e12:Float

The element at row 1 column 2.

e20:Float

The element at row 2 column 0.

e21:Float

The element at row 2 column 1.

e22:Float

The element at row 2 column 2.

Methods

inlineadd(m:Mat3):Mat3

Returns this + m

inlineaddEq(m:Mat3):Mat3

Sets this matrix to this + m and returns this.

inlineappendRotation(rad:Float, axisX:Float, axisY:Float, axisZ:Float):Mat3

Returns this * rotation matrix.

Where rotation matrix is a matrix which rotates rad in radians around the normalized vector (axisX, axisY, axisZ).

inlineappendRotationEq(rad:Float, axisX:Float, axisY:Float, axisZ:Float):Mat3

Sets this matrix to this * rotation matrix, and returns this.

Where rotation matrix is a matrix which rotates rad in radians around the normalized vector (axisX, axisY, axisZ).

inlineappendScale(sx:Float, sy:Float, sz:Float):Mat3

Returns this * scaling matrix.

Where scaling matrix is a matrix which scales sx times, sy times and sz times along the x-axis, y-axis and z-axis respectively.

inlineappendScaleEq(sx:Float, sy:Float, sz:Float):Mat3

Sets this matrix to this * scaling matrix, and returns this.

Where scaling matrix is a matrix which scales sx times, sy times and sz times along the x-axis, y-axis and z-axis respectively.

inlineclone():Mat3

Returns a clone of the matrix.

inlinecopyFrom(m:Mat3):Mat3

Copies values from m and returns this.

inlinedeterminant():Float

Returns the determinant.

inlinefromCols(col0:Vec3, col1:Vec3, col2:Vec3):Mat3

Sets this matrix by column vectors and returns this.

inlinefromEulerXyz(eulerAngles:Vec3):Mat3

Sets this matrix to the rotation matrix represented by Euler angles eulerAngles, and returns this. Rotation order is first X-axis, then rotated Y-axis, finally rotated Z-axis.

inlinefromQuat(q:Quat):Mat3

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

inlinefromRows(row0:Vec3, row1:Vec3, row2:Vec3):Mat3

Sets this matrix by row vectors and returns this.

inlinegetCol(index:Int):Vec3

Returns the indexth column vector of the matrix.

If index is less than 0 or greater than 2, null will be returned.

inlinegetColTo(index:Int, dst:Vec3):Void

Sets dst to the indexth column vector of the matrix.

If index is less than 0 or greater than 2, dst will be set to the zero vector.

inlinegetRow(index:Int):Vec3

Returns the indexth row vector of the matrix.

If index is less than 0 or greater than 2, null will be returned.

inlinegetRowTo(index:Int, dst:Vec3):Void

Sets dst to the indexth row vector of the matrix.

If index is less than 0 or greater than 2, dst will be set to the zero vector.

inlineidentity():Mat3

Sets this matrix to identity matrix and returns this.

inlineinit(e00:Float, e01:Float, e02:Float, e10:Float, e11:Float, e12:Float, e20:Float, e21:Float, e22:Float):Mat3

Sets all elements at once and returns this.

inlineinverse():Mat3

Returns the inverse matrix.

If the determinant is zero, zero matrix is returned.

inlineinverseEq():Mat3

Sets this matrix to the inverse matrix and returns this.

If the determinant is zero, this matrix is set to zero matrix.

inlinemul(m:Mat3):Mat3

Returns this * m

inlinemulEq(m:Mat3):Mat3

Sets this matrix to this * m and returns this.

inlineprependRotation(rad:Float, axisX:Float, axisY:Float, axisZ:Float):Mat3

Returns rotation matrix * this.

Where rotation matrix is a matrix which rotates rad in radians around the normalized vector (axisX, axisY, axisZ).

inlineprependRotationEq(rad:Float, axisX:Float, axisY:Float, axisZ:Float):Mat3

Sets this matrix to rotation matrix * this, and returns this.

Where rotation matrix is a matrix which rotates rad in radians around the normalized vector (axisX, axisY, axisZ).

inlineprependScale(sx:Float, sy:Float, sz:Float):Mat3

Returns scaling matrix * this.

Where scaling matrix is a matrix which scales sx times, sy times and sz times along the x-axis, y-axis and z-axis respectively.

inlineprependScaleEq(sx:Float, sy:Float, sz:Float):Mat3

Sets this matrix to scaling matrix * this, and returns this.

Where scaling matrix is a matrix which scales sx times, sy times and sz times along the x-axis, y-axis and z-axis respectively.

inlinescale(s:Float):Mat3

Returns this * s

inlinescaleEq(s:Float):Mat3

Sets this matrix to this * s and returns this.

inlinesub(m:Mat3):Mat3

Returns this - m

inlinesubEq(m:Mat3):Mat3

Sets this matrix to this - m and returns this.

@:value({ columnMajor : false })inlinetoArray(columnMajor:Bool = false):Array<Float>

Returns an array of the elements of this matrix.

If columnMajor is true, the array is arranged in column-major order. Otherwise, the array is arranged in row-major order.

inlinetoEulerXyz():Vec3

Returns a vector (angleX, angleY, angleZ) represents the Euler angles of this matrix. Rotation order is first X-axis, then rotated Y-axis, finally rotated Z-axis. Note that angleX, angleY, and angleZ are in range of -PI to PI, -PI/2 to PI/2, and -PI to PI respectively.

inlinetoQuat():Quat

Returns a quaternion which represents this matrix.

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

toString():String

Returns the string representation of the matrix.

inlinetrace():Float

Returns the trace.

inlinetranspose():Mat3

Returns the transposed matrix.

inlinetransposeEq():Mat3

Sets this matrix to the transposed matrix and returns this.