Class: Matrix2D

SQR. Matrix2D

Constructor

new Matrix2D()

A matrix that implements 2D affine transformations. Most of the method return the current instance for chaining.
Source:
To Do:
  • Make it column major

Methods

copyFrom(m)

Copies values from m into the current matrix
Parameters:
Name Type Description
m SQR.Matrix2D matrix to copy values from. Can be or {Float32Array}
Source:

copyTo(m)

Copies current matrix values to m
Parameters:
Name Type Description
m SQR.Matrix2D matrix to copy values to. Can be or {Float32Array}
Source:

getTranslation(v) → {SQR.V2}

Returns the translation value as 2d vector.
Parameters:
Name Type Description
v SQR.V2 vector to use to return values in, if ommited a new vector object is returned
Source:
Returns:
2d vector with translation values
Type
SQR.V2

identity()

Resets the matrix to identity values.
Source:

multiply(m)

Multiples current matrix by m and stores result in current matrix.
Parameters:
Name Type Description
m matrix to multiply the current matrix by
Source:

rotate(a)

Applies rotation to matrix
Parameters:
Name Type Description
a angle in radians
Source:

scale(sx, sy)

Applies scale to matrix
Parameters:
Name Type Description
sx x scale
sy y scale
Source:

setRotation(a, m)

Sets the rotation value.
Parameters:
Name Type Description
a angle in radians
m the matrix to set shear to, applies to `this` if ommited
Source:

setScale(sx, sy, m)

Sets the scale values.
Parameters:
Name Type Description
sx x scale
sy y scale
m the matrix to set scale to, applies to `this` if ommited
Source:

setShear(sx, sy, m)

Sets the scale values.
Parameters:
Name Type Description
sx x shear
sy y shear
m the matrix to set shear to, applies to `this` if ommited
Source:

setTranslation(tx, ty, m)

Sets the translation values.
Parameters:
Name Type Description
tx x translation
ty y translation
m the matrix to set translation to, applies to this if ommited
Source:

setTRS(tx, ty, a, sx, sy)

Sets the translation/rotation/scale values at once.
Parameters:
Name Type Description
tx x translation
ty y translation
a angle in radians
sx x scale
sy y scale
Source:

shear(sx, sy)

Applies shear to matrix
Parameters:
Name Type Description
sx x shear
sy y shear
Source:

transformVector(v)

Multiplies the vector by the matrix
Parameters:
Name Type Description
v vector to multiply
Source:
Returns:
the same vector as passed in the parameter, multiplied by this matrix

translate(tx, ty)

Applies translation to matrix
Parameters:
Name Type Description
tx x translation
ty y translation
Source: