4x4 Matrix class.
Note that columns and rows are 0-indexed.
Static variables
Constructor
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
Methods
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.
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
.
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
).
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.
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.