AffineMatrix
Constructors
Creates a matrix of the form:
|a c tx|
|b d ty|
|0 0 1 |
anumber1x component of the first basis vector
bnumber0y component of the first basis vector
cnumber0x component of the second basis vector
dnumber1y component of the second basis vector
txnumber0translation on the x axis
tynumber0translation on the y axis
Constructs an affine matrix from a transform object.
transformConstructs a translation matrix from p1 to p2.
Constructs a rotation matrix.
anglenumberThe angle to rotate by (in degrees)
Constructs a scale matrix.
Constructs a matrix that scales relative to a center point.
Methods
Inverts the matrix.
Multiplies the matrix by another matrix m.
m1.mul(m2); // m1 = m1 * m2
Multiplies only the 2x2 portion portion of this matrix by another matrix
m. Translation is discarded.
Multiplies another matrix m by this matrix, and then stores the result.
m1.preMul(m2); // m1 = m2 * m1
Multiplies only the 2x2 portion portion of another matrix by this matrix, and then stores the result. Translation is discarded.
Scales the basis vectors of the matrix so that they have unit length.
Basis vectors of length 0 will not be changed.
Skews the "Y" basis vector of the matrix by an angle.
anglenumberAn angle in degrees
Translates the matrix such that the center of future scale, rotate and skew
transformations will be origin.
originEnsure that the basis vectors of this matrix are at least as long as the specified length. If a vector is shorter than the specified length it will be set perpendicular to the opposing vector. If both are shorter they will be set to the identity matrix scaled by length.
lengthnumberThe minimum length the basis vectors will have after this method is called
Returns The determinant of the matrix.
Returns true if this matrix exactly equals the matrix m, false
otherwise.
Returns true if the basis vectors of the matrix are orthogonal.
tolerancenumberDEFAULT_TOLERANCEReturns true if the matrix can be inverted.
tolerancenumberDEFAULT_TOLERANCEReturns true if the basis vectors of the matrix are the same length.
Returns true if the matrix mirrors space in either axis.
Returns true if the matrix is the identity.
Applying an identity matrix has no effect.
Returns true if any component of the matrix is NaN.
Returns true if all components of the matrix are finite numbers (not
Infinity or NaN).
Returns true if the matrix is finite, and all of its components are
numbers.
Returns a transform {position, rotation, scale, skew} such that
AffineMatrix.fromTransform(transform) will return the original matrix. It
guarantees:
0 <= rotation < 360-90 < skew < 90(assuming the matrix basis vectors are not collinear)
Notes:
- This will return only one of two possible solutions. You can get the
other one by negating
scaleand rotating by180degrees. - If either of the basis vectors are degenerate (close to zero length),
then this will set
skewto0. - If both of the basis vectors are degenerate, this will set
rotationto0. scalewill always be returned as aVec.
Similar to .toTransform(), except returns a transform with an additional
origin property.
A column-major matrix representing a two-dimensional affine transform.
An affine transformation is a linear transformation that preseves parallel lines.
See https://en.wikipedia.org/wiki/Affine_transformation