Crafty.math.Matrix2D Class

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

Methods

Back to top

.apply()

Applies the matrix transformations to the passed object

public {Vector2D} apply(Vector2D);
{Vector2D} vecRH

vector to be transformed

[Returns]

{Vector2D} the passed vector object after transforming

Back to top

.clone()

Creates an exact, numeric copy of the current matrix

public {Matrix2D} clone();
[Returns]

{Matrix2D}

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
[Returns]

{Matrix2D} this matrix after combination

Back to top

.determinant()

Calculates the determinant of this matrix

public {Number} determinant();
[Returns]

{Number} det(this matrix)

Back to top

.equals()

Checks for the numeric equality of this matrix versus another.

public {Boolean} equals(Matrix2D);
{Matrix2D} mtrxRH
[Returns]

{Boolean} true if the two matrices are numerically equal

Back to top

.invert()

Inverts this matrix if possible

public {Matrix2D} invert();
[Returns]

{Matrix2D} this inverted matrix or the original matrix on failure

Back to top

.isIdentity()

Returns true if this matrix is the identity matrix

public {Boolean} isIdentity();
[Returns]

{Boolean}

Back to top

.isInvertible()

Determines is this matrix is invertible.

public {Boolean} isInvertible();
[Returns]

{Boolean} true if this matrix is invertible

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

[Returns]

{Matrix2D} this matrix after pre-rotation

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
[Returns]

{Matrix2D} this after pre-scaling

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
[Returns]

{Matrix2D} this matrix after pre-translation

Back to top

.rotate()

Applies a counter-clockwise post-rotation to this matrix

public {Matrix2D} rotate(Number);
{Number} rads

angle to rotate in radians

[Returns]

{Matrix2D} this matrix after rotation

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
[Returns]

{Matrix2D} this after post-scaling

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
[Returns]

{Matrix2D} this matrix containing the new values

Back to top

.toString()

Returns the string representation of this matrix.

public {String} toString();
[Returns]

{String}

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
[Returns]

{Matrix2D} this matrix after post-translation