---
title: Namespace: mat2
source: https://vjmap.com/en/doc/Namespace_mat2.html
---

# Namespace: mat2

### Table of contents

#### Type aliases

- [valueType](#valuetype)

#### Functions

- [LDU](#ldu)
- [add](#add)
- [adjoint](#adjoint)
- [clone](#clone)
- [copy](#copy)
- [create](#create)
- [determinant](#determinant)
- [equals](#equals)
- [exactEquals](#exactequals)
- [frob](#frob)
- [fromRotation](#fromrotation)
- [fromScaling](#fromscaling)
- [fromValues](#fromvalues)
- [identity](#identity)
- [invert](#invert)
- [multiply](#multiply)
- [multiplyScalar](#multiplyscalar)
- [multiplyScalarAndAdd](#multiplyscalarandadd)
- [rotate](#rotate)
- [scale](#scale)
- [set](#set)
- [str](#str)
- [subtract](#subtract)
- [transpose](#transpose)

### Type aliases

#### valueType

Ƭ **valueType**: [*mat2type*](#mat2type)

### Functions

#### LDU

▸ **LDU**(`L`: [*mat2type*](#mat2type), `D`: [*mat2type*](#mat2type), `U`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)[]

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

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `L` | [*mat2type*](#mat2type) | the lower triangular matrix |
| `D` | [*mat2type*](#mat2type) | the diagonal matrix |
| `U` | [*mat2type*](#mat2type) | the upper triangular matrix |
| `a` | [*mat2type*](#mat2type) | the input matrix to factorize |

**Returns:** [*mat2type*](#mat2type)[]

___

#### add

▸ **add**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type), `b`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

Adds two mat2's

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the first operand |
| `b` | [*mat2type*](#mat2type) | the second operand |

**Returns:** [*mat2type*](#mat2type)

out

___

#### adjoint

▸ **adjoint**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

Calculates the adjugate of a mat2

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the source matrix |

**Returns:** [*mat2type*](#mat2type)

out

___

#### clone

▸ **clone**(`a`: [*mat2type*](#mat2type)): *Float32Array*

Creates a new mat2 initialized with values from an existing matrix

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `a` | [*mat2type*](#mat2type) | matrix to clone |

**Returns:** *Float32Array*

a new 2x2 matrix

___

#### copy

▸ **copy**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

Copy the values from one mat2 to another

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the source matrix |

**Returns:** [*mat2type*](#mat2type)

out

___

#### create

▸ **create**(): *Float32Array*

Creates a new identity mat2

**Returns:** *Float32Array*

a new 2x2 matrix

___

#### determinant

▸ **determinant**(`a`: [*mat2type*](#mat2type)): *number*

Calculates the determinant of a mat2

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `a` | [*mat2type*](#mat2type) | the source matrix |

**Returns:** *number*

determinant of a

___

#### equals

▸ **equals**(`a`: [*mat2type*](#mat2type), `b`: [*mat2type*](#mat2type)): *boolean*

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

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `a` | [*mat2type*](#mat2type) | The first matrix. |
| `b` | [*mat2type*](#mat2type) | The second matrix. |

**Returns:** *boolean*

True if the matrices are equal, false otherwise.

___

#### exactEquals

▸ **exactEquals**(`a`: [*mat2type*](#mat2type), `b`: [*mat2type*](#mat2type)): *boolean*

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

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `a` | [*mat2type*](#mat2type) | The first matrix. |
| `b` | [*mat2type*](#mat2type) | The second matrix. |

**Returns:** *boolean*

True if the matrices are equal, false otherwise.

___

#### frob

▸ **frob**(`a`: [*mat2type*](#mat2type)): *number*

Returns Frobenius norm of a mat2

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `a` | [*mat2type*](#mat2type) | the matrix to calculate Frobenius norm of |

**Returns:** *number*

Frobenius norm

___

#### fromRotation

▸ **fromRotation**(`out`: [*mat2type*](#mat2type), `rad`: *number*): [*mat2type*](#mat2type)

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` | [*mat2type*](#mat2type) | mat2 receiving operation result |
| `rad` | *number* | the angle to rotate the matrix by |

**Returns:** [*mat2type*](#mat2type)

out

___

#### fromScaling

▸ **fromScaling**(`out`: [*mat2type*](#mat2type), `v`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

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` | [*mat2type*](#mat2type) | mat2 receiving operation result |
| `v` | [*mat2type*](#mat2type) | Scaling vector |

**Returns:** [*mat2type*](#mat2type)

out

___

#### fromValues

▸ **fromValues**(`m00`: *number*, `m01`: *number*, `m10`: *number*, `m11`: *number*): [*mat2type*](#mat2type)

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

**Returns:** [*mat2type*](#mat2type)

out A new 2x2 matrix

___

#### identity

▸ **identity**(`out`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

Set a mat2 to the identity matrix

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |

**Returns:** [*mat2type*](#mat2type)

out

___

#### invert

▸ **invert**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type) \| ``null``

Inverts a mat2

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the source matrix |

**Returns:** [*mat2type*](#mat2type) \| ``null``

out

___

#### multiply

▸ **multiply**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type), `b`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

Multiplies two mat2's

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the first operand |
| `b` | [*mat2type*](#mat2type) | the second operand |

**Returns:** [*mat2type*](#mat2type)

out

___

#### multiplyScalar

▸ **multiplyScalar**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type), `b`: *number*): [*mat2type*](#mat2type)

Multiply each element of the matrix by a scalar.

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the matrix to scale |
| `b` | *number* | amount to scale the matrix's elements by |

**Returns:** [*mat2type*](#mat2type)

out

___

#### multiplyScalarAndAdd

▸ **multiplyScalarAndAdd**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type), `b`: [*mat2type*](#mat2type), `scale`: *number*): [*mat2type*](#mat2type)

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

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving vector |
| `a` | [*mat2type*](#mat2type) | the first operand |
| `b` | [*mat2type*](#mat2type) | the second operand |
| `scale` | *number* | the amount to scale b's elements by before adding |

**Returns:** [*mat2type*](#mat2type)

out

___

#### rotate

▸ **rotate**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type), `rad`: *number*): [*mat2type*](#mat2type)

Rotates a mat2 by the given angle

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the matrix to rotate |
| `rad` | *number* | the angle to rotate the matrix by |

**Returns:** [*mat2type*](#mat2type)

out

___

#### scale

▸ **scale**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type), `v`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

Scales the mat2 by the dimensions in the given vec2

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the matrix to rotate |
| `v` | [*mat2type*](#mat2type) | the vec2 to scale the matrix by |

**Returns:** [*mat2type*](#mat2type)

out

___

#### set

▸ **set**(`out`: [*mat2type*](#mat2type), `m00`: *number*, `m01`: *number*, `m10`: *number*, `m11`: *number*): [*mat2type*](#mat2type)

Set the components of a mat2 to the given values

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | 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) |

**Returns:** [*mat2type*](#mat2type)

out

___

#### str

▸ **str**(`a`: [*mat2type*](#mat2type)): *string*

Returns a string representation of a mat2

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `a` | [*mat2type*](#mat2type) | matrix to represent as a string |

**Returns:** *string*

string representation of the matrix

___

#### subtract

▸ **subtract**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type), `b`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

Subtracts matrix b from matrix a

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the first operand |
| `b` | [*mat2type*](#mat2type) | the second operand |

**Returns:** [*mat2type*](#mat2type)

out

___

#### transpose

▸ **transpose**(`out`: [*mat2type*](#mat2type), `a`: [*mat2type*](#mat2type)): [*mat2type*](#mat2type)

Transpose the values of a mat2

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat2type*](#mat2type) | the receiving matrix |
| `a` | [*mat2type*](#mat2type) | the source matrix |

**Returns:** [*mat2type*](#mat2type)

out


<a name="modulesmat2dmd"></a>

[vjmap](#readmemd) / [Exports](#modulesmd) / mat2d
