4x4 Matrix class.

Note that columns and rows are 0-indexed.

Static variables

@:value(0)staticnumCreations:Int = 0

The number of instance creation.

Constructor

@:value({ e33 : 1, e32 : 0, e31 : 0, e30 : 0, e23 : 0, e22 : 1, e21 : 0, e20 : 0, e13 : 0, e12 : 0, e11 : 1, e10 : 0, e03 : 0, e02 : 0, e01 : 0, e00 : 1 })inlinenew(e00:Float = 1, e01:Float = 0, e02:Float = 0, e03:Float = 0, e10:Float = 0, e11:Float = 1, e12:Float = 0, e13:Float = 0, e20:Float = 0, e21:Float = 0, e22:Float = 1, e23:Float = 0, e30:Float = 0, e31:Float = 0, e32:Float = 0, e33: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.

e03:Float

The element at row 0 column 3.

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.

e13:Float

The element at row 1 column 3.

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.

e23:Float

The element at row 2 column 3.

e30:Float

The element at row 3 column 0.

e31:Float

The element at row 3 column 1.

e32:Float

The element at row 3 column 2.

e33:Float

The element at row 3 column 3.

Methods

inlineadd(m:Mat4):Mat4

Returns this + m

inlineaddEq(m:Mat4):Mat4

Sets this matrix to this + m and returns this.

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

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):Mat4

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):Mat4

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):Mat4

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.

inlineappendTranslation(tx:Float, ty:Float, tz:Float):Mat4

Returns this * translation matrix.

Where translation matrix is a matrix which translates sx, sy and sz along the x-axis, y-axis and z-axis respectively.

inlineappendTranslationEq(tx:Float, ty:Float, tz:Float):Mat4

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

Where translation matrix is a matrix which translates sx, sy and sz along the x-axis, y-axis and z-axis respectively.

inlineclone():Mat4

Returns a clone of the matrix.

inlinecopyFrom(m:Mat4):Mat4

Copies values from m and returns this.

inlinedeterminant():Float

Returns the determinant.

inlinefromMat3(m:Mat3):Mat4

Sets this matrix to the extension of m and returns this.

this.e33 is set to 1 and other components don't exist in m are set to 0.

inlinefromTransform(transform:Transform):Mat4

Sets this matrix to the representation of transform and returns this.

inlineidentity():Mat4

Sets this matrix to identity matrix and returns this.

inlineinit(e00:Float, e01:Float, e02:Float, e03:Float, e10:Float, e11:Float, e12:Float, e13:Float, e20:Float, e21:Float, e22:Float, e23:Float, e30:Float, e31:Float, e32:Float, e33:Float):Mat4

Sets all elements at once and returns this.

inlineinverse():Mat4

Returns the inverse matrix.

If the determinant is zero, zero matrix is returned.

inlineinverseEq():Mat4

Sets this matrix to the inverse matrix and returns this.

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

inlinelookAt(eyeX:Float, eyeY:Float, eyeZ:Float, atX:Float, atY:Float, atZ:Float, upX:Float, upY:Float, upZ:Float):Mat4

Sets this matrix to view matrix and returns this.

Where view matrix is a matrix which represents the viewing transformation with eyes at (eyeX, eyeY, eyeZ), fixation point at (atX, atY, atZ), and up vector (upX, upY, upZ).

inlinemul(m:Mat4):Mat4

Returns this * m

inlinemulEq(m:Mat4):Mat4

Sets this matrix to this * m and returns this.

inlineortho(width:Float, height:Float, near:Float, far:Float):Mat4

Sets this matrix to orthogonal projection matrix and returns this.

Where orthogonal projection matrix is a matrix which represents the orthogonal projection transformation with screen width and height width, height, and z-value of near and far clipping plane near, far.

inlineperspective(fovY:Float, aspect:Float, near:Float, far:Float):Mat4

Sets this matrix to perspecive projection matrix and returns this.

Where perspecive projection matrix is a matrix which represents the perspective projection transformation with field of view in the y direction fovY in radians, aspect ratio aspect, and z-value of near and far clipping plane near, far.

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

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):Mat4

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):Mat4

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):Mat4

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.

inlineprependTranslation(tx:Float, ty:Float, tz:Float):Mat4

Returns translation matrix * this.

Where translation matrix is a matrix which translates sx, sy and sz along the x-axis, y-axis and z-axis respectively.

inlineprependTranslationEq(tx:Float, ty:Float, tz:Float):Mat4

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

Where translation matrix is a matrix which translates sx, sy and sz along the x-axis, y-axis and z-axis respectively.

inlinescale(s:Float):Mat4

Returns this * s

inlinescaleEq(s:Float):Mat4

Sets this matrix to this * s and returns this.

inlinesub(m:Mat4):Mat4

Returns this - m

inlinesubEq(m:Mat4):Mat4

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.

toString():String

Returns the string representation of the matrix.

inlinetrace():Float

Returns the trace.

inlinetranspose():Mat4

Returns the transposed matrix.

inlinetransposeEq():Mat4

Sets this matrix to the transposed matrix and returns this.