Matrix3 is a 3x3 transformation matrix particularly useful for two-dimensional transformation. It can be used for rotation, scale and skewing of a two-dimensional object.

Although a 3x3 matrix is represented, configurable values can be considered as a 3x2 matrix:

[ a, c, tx ]
[ b, d, ty ]
[ 0, 0,  1 ]

Values are stored in column-major order for GLSL compatibility.

Static variables

statica:Float

The matrix a component, used in scaling and skewing (default is 1)

staticb:Float

The matrix b component, used in rotation and skewing (default is 0)

staticc:Float

The matrix c component, used in rotation and skewing (default is 0)

staticd:Float

The matrix d component, used in scaling and skewing (default is 1)

statictx:Float

The matrix tx component, used in translation (default is 0)

staticty:Float

The matrix ty component, used in translation (default is 0)

Static methods

staticinlineclone(this:Float32Array):Matrix3

Creates a duplicate of the current Matrix3

Returns:

A duplicate Matrix3 instance

staticconcat(this:Float32Array, m:Matrix3):Void

Concatenates the values of a second matrix to the current Matrix3, combining the effects of both. This is the same as matrix multiplication. The second matrix is not modified.

Parameters:

m

A second Matrix3 to concatenate to the current instance

staticcopyColumnFrom(this:Float32Array, column:Int, vector4:Vector4):Void

Copies the x and y components from a Vector4 instance to the a/c, b/d or the tx/ty column of the current matrix

Parameters:

column

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

vector4

The Vector4 instance to copy from

staticcopyColumnTo(this:Float32Array, column:Int, vector4:Vector4):Void

Copies a column of the current matrix into a Vector4 instance. The w value will not be modified.

Parameters:

column

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

vector4

The Vector4 instance to copy to

staticcopyFrom(this:Float32Array, sourceMatrix3:Matrix3):Void

Copies the values of another Matrix3 and applies it to the current instance

Parameters:

sourceMatrix3

The Matrix3 to copy from

staticcopyRowFrom(this:Float32Array, row:Int, vector4:Vector4):Void

Copies the values of a Vector4 instance into a row of the current matrix

Parameters:

row

The row to copy into (0 or 1)

vector4

The Vector4 instance to copy from

staticcopyRowTo(this:Float32Array, row:Int, vector4:Vector4):Void

Copies a row of the current matrix into a Vector4 instance. The w value will not be modified.

Parameters:

row

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

vector4

The Vector4 instance to copy from

@:value({ yTranslate : 0, xTranslate : 0, rotation : 0 })staticcreateBox(this:Float32Array, scaleX:Float, scaleY:Float, rotation:Float = 0, xTranslate:Float = 0, yTranslate:Float = 0):Void

Applies a two-dimensional transformation to the current matrix.

This is the same as calling identity(), rotate(), scale() then translate() with these values.

Parameters:

scaleX

An x scale transformation value

scaleY

A y scale transformation value

rotation

(Optional) A rotation value (default is 0)

xTranslate

(Optional) A translate x value (default is 0)

yTranslate

(Optional) A translate y value (default is 0)

@:value({ yTranslate : 0, xTranslate : 0, rotation : 0 })staticcreateGradientBox(this:Float32Array, width:Float, height:Float, rotation:Float = 0, xTranslate:Float = 0, yTranslate:Float = 0):Void

Creates a matrix to use for a linear gradient fill

Parameters:

width

The width of the gradient fill

height

The height of the gradient fill

rotation

(Optional) A rotation for the gradient fill (default is 0)

xTranslate

(Optional) An x offset for the gradient fill (default is 0)

yTranslate

(Optional) A y offset for the gradient fill (default is 0)

Returns:

A new Matrix instance

@:value({ result : null })staticdeltaTransformVector(this:Float32Array, Vector2:Vector2, ?result:Vector2):Vector2

Transforms a Vector2 instance by the current matrix, without considering the tx and ty values of the matrix

Parameters:

result

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

Returns:

A new Vector2 instance representing the transformed values

staticequals(this:Float32Array, matrix3:Matrix3):Bool

Check if two matrices have the same values

Returns:

Whether both matrices are equal

staticidentity(this:Float32Array):Void

Resets the matrix to default identity values

staticinvert(this:Float32Array):Matrix3

Inverts the values of the current matrix

Returns:

The current matrix instance

staticrotate(this:Float32Array, theta:Float):Void

Applies rotation to the current matrix

Parameters:

theta

A rotation value in degrees

staticscale(this:Float32Array, sx:Float, sy:Float):Void

Scales the current matrix

Parameters:

sx

The x scale to apply

sy

The y scale to apply

staticsetTo(this:Float32Array, a:Float, b:Float, c:Float, d:Float, tx:Float, ty:Float):Void

Sets the values of the current matrix

Parameters:

a

The new matrix a value

b

The new matrix b value

c

The new matrix c value

d

The new matrix d value

tx

The new matrix tx value

ty

The new matrix ty value

@:value({ result : null })statictransformRect(this:Float32Array, rect:Rectangle, ?result:Rectangle):Rectangle

Transforms a Rectangle instance by the current matrix and returns Rectangle with the bounds of the transformed rectangle.

Parameters:

transform

A Matrix3 instance to transform by

result

(Optional) A Rectangle instance to use for the result

Returns:

A Rectangle represented the transformed bounds

@:value({ result : null })statictransformVector(this:Float32Array, pos:Vector2, ?result:Vector2):Vector2

Transforms a Vector2 instance by the current matrix

Parameters:

result

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

Returns:

A new Vector2 instance representing the transformed values

staticinlinetranslate(this:Float32Array, dx:Float, dy:Float):Void

Adjusts the tx and ty of the current matrix

Parameters:

dx

The x amount to translate

dy

The y amount to translate