craftyjs.github.com

Crafty.math.Matrix2D

The third row is always assumed to be [0, 0, 1].

Matrix2D uses the following form, as per the whatwg.org specifications for canvas.transform(): [a, c, e] [b, d, f] [0, 0, 1]

public {Matrix2D} new Matrix2D();

public {Matrix2D} new Matrix2D(Matrix2D);

public {Matrix2D} new Matrix2D(Number, Number, Number, Number, Number, Number);

{Matrix2D|Number=1} a
{Number=0} b
{Number=0} c
{Number=1} d
{Number=0} e
{Number=0} f
Back to top

.apply

Applies the matrix transformations to the passed object

public {Vector2D} apply(Vector2D);

{Vector2D} vecRH
vector to be transformed
Back to top

.clone

Creates an exact, numeric copy of the current matrix

public {Matrix2D} clone();

Back to top

.combine

Multiplies this matrix with another, overriding the values of this matrix. The passed matrix is assumed to be on the right-hand side.

public {Matrix2D} combine(Matrix2D);

{Matrix2D} mtrxRH
Back to top

.equals

Checks for the numeric equality of this matrix versus another.

public {Boolean} equals(Matrix2D);

{Matrix2D} mtrxRH
Back to top

.determinant

Calculates the determinant of this matrix

public {Number} determinant();

Back to top

.invert

Inverts this matrix if possible

public {Matrix2D} invert();

See Also

Back to top

.isIdentity

Returns true if this matrix is the identity matrix

public {Boolean} isIdentity();

Back to top

.isInvertible

Determines is this matrix is invertible.

public {Boolean} isInvertible();

See Also

Back to top

.preRotate

Applies a counter-clockwise pre-rotation to this matrix

public {Matrix2D} preRotate(Number);

{number} rads
angle to rotate in radians
Back to top

.preScale

Applies a pre-scaling to this matrix

public {Matrix2D} preScale(Number[, Number]);

{Number} scalarX
{Number} [scalarY] scalarX is used if scalarY is undefined
Back to top

.preTranslate

Applies a pre-translation to this matrix

public {Matrix2D} preTranslate(Vector2D);

public {Matrix2D} preTranslate(Number, Number);

{Number|Vector2D} dx
{Number} dy
Back to top

.rotate

Applies a counter-clockwise post-rotation to this matrix

public {Matrix2D} rotate(Number);

{Number} rads
angle to rotate in radians
Back to top

.scale

Applies a post-scaling to this matrix

public {Matrix2D} scale(Number[, Number]);

{Number} scalarX
{Number} [scalarY] scalarX is used if scalarY is undefined
Back to top

.setValues

Sets the values of this matrix

public {Matrix2D} setValues(Matrix2D);

public {Matrix2D} setValues(Number, Number, Number, Number, Number, Number);

{Matrix2D|Number} a
{Number} b
{Number} c
{Number} d
{Number} e
{Number} f
Back to top

.toString

Returns the string representation of this matrix.

public {String} toString();

Back to top

.translate

Applies a post-translation to this matrix

public {Matrix2D} translate(Vector2D);

public {Matrix2D} translate(Number, Number);

{Number|Vector2D} dx
{Number} dy