Matrix4 is a 4x4 matrix, useful for 3D calculations

Constructor

new (?data:Float32Array)

Creates a new matrix instance

Parameters:

data

(Optional) A Float32Array of 16 values to use for this matrix

Variables

read onlydeterminant:Float

Gets the determinant of the matrix

position:Vector4

Gets or sets the position value of this matrix

Methods

append (lhs:Matrix4):Void

Appends a second matrix by multiplying its values against the current one

Parameters:

lhs

A second matrix instance

appendRotation (degrees:Float, axis:Vector4, ?pivotPoint:Vector4):Void

Appends rotation to the current matrix

Parameters:

degrees

A rotation value (in degrees)

axis

The coordinate position of the rotation axis

pivotPoint

(Optional) A pivot point to use in the rotation

appendScale (xScale:Float, yScale:Float, zScale:Float):Void

Appends a scale value to the current matrix

Parameters:

xScale

The x scale to append

yScale

The y scale to append

zScale

The z scale to append

appendTranslation (x:Float, y:Float, z:Float):Void

Increases the position/translation of the current matrix

Parameters:

x

The x amount to offset the current position

y

The y amount to offset the current position

z

The z amount to offset the current position

clone ():Matrix4

Creates a duplicate of the current Matrix4

Returns:

A new Matrix4 with the same values as the current matrix

copyColumnFrom (column:Int, vector:Vector4):Void

Copies a column of data from a Vector4 instance into the values of this matrix

Parameters:

column

The column to copy into (0, 1, 2 or 3)

vector

The Vector4 copy from

copyColumnTo (column:Int, vector:Vector4):Void

Copies a column of data from the current matrix into a Vector4 instance

Parameters:

column

The column to copy (0, 1, 2 or 3)

vector

The Vector4 copy to

copyFrom (other:Matrix4):Void

Copies the values of another Matrix4 into the current matrix

Parameters:

other

A Matrix4 instance to copy from

copyRowFrom (row:Int, vector:Vector4):Void

Copies a row of data from a Vector4 instance into the values of this matrix

Parameters:

row

The row to copy into (0, 1, 2 or 3)

vector

The Vector4 copy from

copyRowTo (row:Int, vector:Vector4):Void

Copies a row of data from the current matrix into a Vector4 instance

Parameters:

column

The row to copy (0, 1, 2 or 3)

vector

The Vector4 copy to

create2D (a:Float, b:Float, c:Float, d:Float, tx:Float = 0, ty:Float = 0):Void

Resets the current matrix using two-dimensional transform values

Parameters:

a

A two-dimensional matrix a value

b

A two-dimensional matrix b value

c

A two-dimensional matrix c value

d

A two-dimensional matrix d value

tx

(Optional) A two-dimensional matrix tx value (default is 0)

ty

(Optional) A two-dimensional matrix ty value (default is 0)

createOrtho (left:Float, right:Float, bottom:Float, top:Float, zNear:Float, zFar:Float):Void

Initializes this matrix with values for an orthographic projection, useful in rendering

Parameters:

left

The left (or x0) coordinate for the projection

right

The right (or x1) coordinate for the projection

bottom

The bottom (or y0) coordinate for the projection

top

The top (or y1) coordinate for the projection

zNear

The near depth-clipping plane position

zFar

The far depth-clipping plane position

deltaTransformVector (v:Vector4, ?result:Vector4):Vector4

Returns the transformation matrix's translation, rotation, and scale settings as a Vector of three Vector4 objects.

identity ():Void

Resets the current matrix using default identity values

interpolateTo (toMat:Matrix4, percent:Float):Void

Interpolates the current matrix toward another matrix, resetting the values of the current matrix

Parameters:

toMat

The second Matrix4 object to interpolate toward

percetn

The percentage value to interpolate by

invert ():Bool

Attempts to invert the current matrix, so long as the determinant is greater than zero

Returns:

Whether the invert operation was successful

pointAt (pos:Vector4, ?at:Vector4, ?up:Vector4):Void

Sets the matrix values as a transformation orientated toward a certain vector position

Parameters:

pos

A target vector position in absolute coordinates

at

(Optional) A vector relative to this matrix which defines the current direction

up

(Optional) A vector relative to this matrix which defines the "up" direction

prepend (rhs:Matrix4):Void

Prepends a right-hand matrix to the current matrix

Parameters:

rhx

A right-hand Matrix4 to append

prependRotation (degrees:Float, axis:Vector4, ?pivotPoint:Vector4):Void

Prepends rotation to this matrix

Parameters:

degrees

The rotation amount in degrees

axis

The rotation axis

pivotPoint

(Optional) A pivot point for the rotation

prependScale (xScale:Float, yScale:Float, zScale:Float):Void

Prepends scale to this matrix

Parameters:

xScale

An x scale value

yScale

A y scale value

zScale

A z scale value

prependTranslation (x:Float, y:Float, z:Float):Void

Prepends translation values to this matrix

Parameters:

x

An x translation value

y

A y translation value

z

A z translation value

transformVector (v:Vector4, ?result:Vector4):Vector4

Transforms a Vector4 instance using the current matrix

Parameters:

result

(Optional) An existing Vector2 instance to fill with the result

Returns:

The resulting Vector4 instance

transformVectors (ain:Float32Array, aout:Float32Array):Void

Transforms a series of [x, y, z] value pairs at once

Parameters:

ain

An input Float32Array to transform

aout

An output Float32Array to write to

transpose ():Void

Transposes the current matrix

Static methods

staticfromMatrix3 (matrix3:Matrix3):Matrix4

staticinterpolate (thisMat:Matrix4, toMat:Matrix4, percent:Float, ?result:Matrix4):Matrix4

Interpolates from one Matrix4 instance to another, given a percentage between the two

Parameters:

thisMat

The first Matrix4 object to start from

toMat

The second Matrix4 object to interpolate toward

percent

The percentage value to interpolate by

result

(Optional) A Matrix4 instance to use when returning the result

Returns:

A Matrix4 with the resulting value