Constructor
new Matrix(a, b, c, d, tx, ty)
Construct new instance of affine transformation matrix
If parameters omitted, construct identity matrix a = 1, d = 1
If parameters omitted, construct identity matrix a = 1, d = 1
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
a |
number
|
1 | position(0,0) sx*cos(alpha) |
b |
number
|
0 | position (0,1) sx*sin(alpha) |
c |
number
|
0 | position (1,0) -sy*sin(alpha) |
d |
number
|
1 | position (1,1) sy*cos(alpha) |
tx |
number
|
0 | position (2,0) translation by x |
ty |
number
|
0 | position (2,1) translation by y |
Classes
Methods
equalTo(matrix) → {boolean}
Returns true if two matrix are equal parameter by parameter
- Source:
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix
|
other matrix |
Returns:
- Type:
-
boolean
true if equal, false otherwise
multiply(other_matrix) → {Matrix}
Returns result of multiplication of this matrix by other matrix
- Source:
Parameters:
Name | Type | Description |
---|---|---|
other_matrix |
Matrix
|
matrix to multiply by |
Returns:
- Type:
-
Matrix
rotate(angle, centerX, centerY) → {Matrix}
Return new matrix as a result of multiplication of the current matrix
by the matrix that defines rotation by given angle (in radians) around
center of rotation (centerX,centerY) in counterclockwise direction
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
angle |
number
|
angle in radians | |
centerX |
number
|
0 | center of rotation |
centerY |
number
|
0 | center of rotation |
Returns:
- Type:
-
Matrix
scale(sx, sy) → {Matrix}
Return new matrix as a result of multiplication of the current matrix
by the matrix (sx,0,0,sy,0,0) that defines scaling
- Source:
Parameters:
Name | Type | Description |
---|---|---|
sx |
number
|
|
sy |
number
|
Returns:
- Type:
-
Matrix
transform(vector) → {Array.<number>}
Transform vector [x,y] using transformation matrix.
Vector [x,y] is an abstract array[2] of numbers and not a FlattenJS object
The result is also an abstract vector [x',y'] = A * [x,y]:
Vector [x,y] is an abstract array[2] of numbers and not a FlattenJS object
The result is also an abstract vector [x',y'] = A * [x,y]:
[x' [ ax + by + tx
y' = cx + dy + ty
1] 1 ]
- Source:
Parameters:
Name | Type | Description |
---|---|---|
vector |
Array.<number>
|
array[2] of numbers |
Returns:
- Type:
-
Array.<number>
transformation result - array[2] of numbers
translate(vector, tx, ty) → {Matrix}
Return new matrix as a result of multiplication of the current matrix
by the matrix(1,0,0,1,tx,ty)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
vector |
Vector
|
Translation by vector or |
tx |
number
|
translation by x-axis |
ty |
number
|
translation by y-axis |
Returns:
- Type:
-
Matrix