# Matrix

Class representing an affine transformation 3x3 matrix:

         [ a  c  tx
    A =    b  d  ty
           0  0  1  ]

## 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

Source:
  - classes/matrix.js, line 14

##### 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

Matrix

### Methods

#### clone() → {Matrix}

Return new cloned instance of matrix

Source:
  - classes/matrix.js, line 38

##### Returns:

Type:
  `Matrix`

#### equalTo(matrix) → {boolean}

Returns true if two matrix are equal parameter by parameter

Source:
  - classes/matrix.js, line 127

##### 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:
  - classes/matrix.js, line 66

##### Parameters:

Name | Type | Description
--- | --- | ---
`other_matrix` | `Matrix` | matrix to multiply by

##### Returns:

Type:
  `Matrix`

#### rotate(angle) → {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 point (0,0) in counter clockwise direction

Source:
  - classes/matrix.js, line 105

##### Parameters:

Name | Type | Description
--- | --- | ---
`angle` | `number` | angle in radians

##### 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:
  - classes/matrix.js, line 118

##### 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]: `[x' [ ax + by + tx y' = cx + dy + ty 1] 1 ]`

Source:
  - classes/matrix.js, line 54

##### Parameters:

Name | Type | Description
--- | --- | ---
`vector` | `Array.<number>` | array[2] of numbers

##### Returns:

Type:
  `Array.<number>`

transformation result - array[2] of numbers

#### translate(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:
  - classes/matrix.js, line 84

##### Parameters:

Name | Type | Description
--- | --- | ---
`tx` | `number` | translation by x
`ty` | `number` | translation by y

##### Returns:

Type:
  `Matrix`