JSDoc: Module: mat2d

# Module: mat2d

A mat2d contains six elements defined as:

    [a, c, tx,
     b, d, ty]

This is a short form for the 3x3 matrix:

    [a, c, tx,
     b, d, ty,
     0, 0, 1]

The last row is ignored so the array is shorter and operations are faster.

Source:
  - mat2d.js, line 23

### Methods

#### (static) add(out, a, b) → {mat2d}

Adds two mat2d's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the first operand
`b` | mat2d | the second operand

Source:
  - mat2d.js, line 362

##### Returns:

out

Type
  mat2d

#### (static) clone(a) → {mat2d}

Creates a new mat2d initialized with values from an existing matrix

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | mat2d | matrix to clone

Source:
  - mat2d.js, line 64

##### Returns:

a new 2x3 matrix

Type
  mat2d

#### (static) copy(out, a) → {mat2d}

Copy the values from one mat2d to another

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the source matrix

Source:
  - mat2d.js, line 82

##### Returns:

out

Type
  mat2d

#### (static) create() → {mat2d}

Creates a new identity mat2d

Source:
  - mat2d.js, line 47

##### Returns:

a new 2x3 matrix

Type
  mat2d

#### (static) determinant(a) → {Number}

Calculates the determinant of a mat2d

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | mat2d | the source matrix

Source:
  - mat2d.js, line 184

##### Returns:

determinant of a

Type
  Number

#### (static) equals(a, b) → {Boolean}

Returns whether or not the matrices have approximately the same elements in the same position.

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | mat2d | The first matrix.
`b` | mat2d | The second matrix.

Source:
  - mat2d.js, line 445

##### Returns:

True if the matrices are equal, false otherwise.

Type
  Boolean

#### (static) exactEquals(a, b) → {Boolean}

Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | mat2d | The first matrix.
`b` | mat2d | The second matrix.

Source:
  - mat2d.js, line 434

##### Returns:

True if the matrices are equal, false otherwise.

Type
  Boolean

#### (static) frob(a) → {Number}

Returns Frobenius norm of a mat2d

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | mat2d | the matrix to calculate Frobenius norm of

Source:
  - mat2d.js, line 350

##### Returns:

Frobenius norm

Type
  Number

#### (static) fromRotation(out, rad) → {mat2d}

Creates a matrix from a given angle This is equivalent to (but much faster than): mat2d.identity(dest); mat2d.rotate(dest, dest, rad);

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | mat2d receiving operation result
`rad` | Number | the angle to rotate the matrix by

Source:
  - mat2d.js, line 280

##### Returns:

out

Type
  mat2d

#### (static) fromScaling(out, v) → {mat2d}

Creates a matrix from a vector scaling This is equivalent to (but much faster than): mat2d.identity(dest); mat2d.scale(dest, dest, vec);

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | mat2d receiving operation result
`v` | vec2 | Scaling vector

Source:
  - mat2d.js, line 302

##### Returns:

out

Type
  mat2d

#### (static) fromTranslation(out, v) → {mat2d}

Creates a matrix from a vector translation This is equivalent to (but much faster than): mat2d.identity(dest); mat2d.translate(dest, dest, vec);

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | mat2d receiving operation result
`v` | vec2 | Translation vector

Source:
  - mat2d.js, line 323

##### Returns:

out

Type
  mat2d

#### (static) fromValues(a, b, c, d, tx, ty) → {mat2d}

Create a new mat2d with the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | Number | Component A (index 0)
`b` | Number | Component B (index 1)
`c` | Number | Component C (index 2)
`d` | Number | Component D (index 3)
`tx` | Number | Component TX (index 4)
`ty` | Number | Component TY (index 5)

Source:
  - mat2d.js, line 119

##### Returns:

A new mat2d

Type
  mat2d

#### (static) identity(out) → {mat2d}

Set a mat2d to the identity matrix

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix

Source:
  - mat2d.js, line 98

##### Returns:

out

Type
  mat2d

#### (static) invert(out, a) → {mat2d}

Inverts a mat2d

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the source matrix

Source:
  - mat2d.js, line 159

##### Returns:

out

Type
  mat2d

#### (static) mul()

Alias for mat2d.multiply

Source:
  - mat2d.js, line 460

#### (static) multiply(out, a, b) → {mat2d}

Multiplies two mat2d's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the first operand
`b` | mat2d | the second operand

Source:
  - mat2d.js, line 196

##### Returns:

out

Type
  mat2d

#### (static) multiplyScalar(out, a, b) → {mat2d}

Multiply each element of the matrix by a scalar.

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the matrix to scale
`b` | Number | amount to scale the matrix's elements by

Source:
  - mat2d.js, line 398

##### Returns:

out

Type
  mat2d

#### (static) multiplyScalarAndAdd(out, a, b, scale) → {mat2d}

Adds two mat2d's after multiplying each element of the second operand by a scalar value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving vector
`a` | mat2d | the first operand
`b` | mat2d | the second operand
`scale` | Number | the amount to scale b's elements by before adding

Source:
  - mat2d.js, line 417

##### Returns:

out

Type
  mat2d

#### (static) rotate(out, a, rad) → {mat2d}

Rotates a mat2d by the given angle

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the matrix to rotate
`rad` | Number | the angle to rotate the matrix by

Source:
  - mat2d.js, line 216

##### Returns:

out

Type
  mat2d

#### (static) scale(out, a, v) → {mat2d}

Scales the mat2d by the dimensions in the given vec2

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the matrix to translate
`v` | vec2 | the vec2 to scale the matrix by

Source:
  - mat2d.js, line 237

##### Returns:

out

Type
  mat2d

#### (static) set(out, a, b, c, d, tx, ty) → {mat2d}

Set the components of a mat2d to the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | Number | Component A (index 0)
`b` | Number | Component B (index 1)
`c` | Number | Component C (index 2)
`d` | Number | Component D (index 3)
`tx` | Number | Component TX (index 4)
`ty` | Number | Component TY (index 5)

Source:
  - mat2d.js, line 142

##### Returns:

out

Type
  mat2d

#### (static) str(a) → {String}

Returns a string representation of a mat2d

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | mat2d | matrix to represent as a string

Source:
  - mat2d.js, line 339

##### Returns:

string representation of the matrix

Type
  String

#### (static) sub()

Alias for mat2d.subtract

Source:
  - mat2d.js, line 466

#### (static) subtract(out, a, b) → {mat2d}

Subtracts matrix b from matrix a

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the first operand
`b` | mat2d | the second operand

Source:
  - mat2d.js, line 380

##### Returns:

out

Type
  mat2d

#### (static) translate(out, a, v) → {mat2d}

Translates the mat2d by the dimensions in the given vec2

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2d | the receiving matrix
`a` | mat2d | the matrix to translate
`v` | vec2 | the vec2 to translate the matrix by

Source:
  - mat2d.js, line 257

##### Returns:

out

Type
  mat2d