# Module: mat2

2x2 Matrix

Source:
  - mat2.js, line 3

### Methods

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

Adds two mat2's

##### Parameters:

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

Source:
  - mat2.js, line 321

##### Returns:

out

Type
  mat2

#### (static) adjoint(out, a) → {mat2}

Calculates the adjugate of a mat2

##### Parameters:

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

Source:
  - mat2.js, line 161

##### Returns:

out

Type
  mat2

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

Creates a new mat2 initialized with values from an existing matrix

##### Parameters:

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

Source:
  - mat2.js, line 30

##### Returns:

a new 2x2 matrix

Type
  mat2

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

Copy the values from one mat2 to another

##### Parameters:

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

Source:
  - mat2.js, line 46

##### Returns:

out

Type
  mat2

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

Creates a new identity mat2

Source:
  - mat2.js, line 13

##### Returns:

a new 2x2 matrix

Type
  mat2

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

Calculates the determinant of a mat2

##### Parameters:

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

Source:
  - mat2.js, line 178

##### 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` | mat2 | The first matrix.
`b` | mat2 | The second matrix.

Source:
  - mat2.js, line 363

##### 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` | mat2 | The first matrix.
`b` | mat2 | The second matrix.

Source:
  - mat2.js, line 352

##### Returns:

True if the matrices are equal, false otherwise.

Type
  Boolean

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

Returns Frobenius norm of a mat2

##### Parameters:

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

Source:
  - mat2.js, line 293

##### Returns:

Frobenius norm

Type
  Number

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

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

##### Parameters:

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

Source:
  - mat2.js, line 248

##### Returns:

out

Type
  mat2

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

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

##### Parameters:

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

Source:
  - mat2.js, line 269

##### Returns:

out

Type
  mat2

#### (static) fromValues(m00, m01, m10, m11) → {mat2}

Create a new mat2 with the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`m00` | Number | Component in column 0, row 0 position (index 0)
`m01` | Number | Component in column 0, row 1 position (index 1)
`m10` | Number | Component in column 1, row 0 position (index 2)
`m11` | Number | Component in column 1, row 1 position (index 3)

Source:
  - mat2.js, line 77

##### Returns:

out A new 2x2 matrix

Type
  mat2

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

Set a mat2 to the identity matrix

##### Parameters:

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

Source:
  - mat2.js, line 60

##### Returns:

out

Type
  mat2

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

Inverts a mat2

##### Parameters:

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

Source:
  - mat2.js, line 135

##### Returns:

out

Type
  mat2

#### (static) LDU(L, D, U, a)

Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix

##### Parameters:

Name | Type | Description
--- | --- | ---
`L` | mat2 | the lower triangular matrix
`D` | mat2 | the diagonal matrix
`U` | mat2 | the upper triangular matrix
`a` | mat2 | the input matrix to factorize

Source:
  - mat2.js, line 305

#### (static) mul()

Alias for mat2.multiply

Source:
  - mat2.js, line 409

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

Multiplies two mat2's

##### Parameters:

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

Source:
  - mat2.js, line 190

##### Returns:

out

Type
  mat2

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

Multiply each element of the matrix by a scalar.

##### Parameters:

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

Source:
  - mat2.js, line 380

##### Returns:

out

Type
  mat2

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

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

##### Parameters:

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

Source:
  - mat2.js, line 397

##### Returns:

out

Type
  mat2

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

Rotates a mat2 by the given angle

##### Parameters:

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

Source:
  - mat2.js, line 208

##### Returns:

out

Type
  mat2

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

Scales the mat2 by the dimensions in the given vec2

##### Parameters:

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

Source:
  - mat2.js, line 227

##### Returns:

out

Type
  mat2

#### (static) set(out, m00, m01, m10, m11) → {mat2}

Set the components of a mat2 to the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | mat2 | the receiving matrix
`m00` | Number | Component in column 0, row 0 position (index 0)
`m01` | Number | Component in column 0, row 1 position (index 1)
`m10` | Number | Component in column 1, row 0 position (index 2)
`m11` | Number | Component in column 1, row 1 position (index 3)

Source:
  - mat2.js, line 96

##### Returns:

out

Type
  mat2

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

Returns a string representation of a mat2

##### Parameters:

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

Source:
  - mat2.js, line 283

##### Returns:

string representation of the matrix

Type
  String

#### (static) sub()

Alias for mat2.subtract

Source:
  - mat2.js, line 415

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

Subtracts matrix b from matrix a

##### Parameters:

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

Source:
  - mat2.js, line 337

##### Returns:

out

Type
  mat2

#### (static) transpose(out, a) → {mat2}

Transpose the values of a mat2

##### Parameters:

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

Source:
  - mat2.js, line 111

##### Returns:

out

Type
  mat2