---
title: Namespace: mat3
source: https://vjmap.com/en/doc/Namespace_mat3.html
---

# Namespace: mat3

### Table of contents

#### Type aliases

- [valueType](#valuetype)

#### Functions

- [add](#add)
- [adjoint](#adjoint)
- [clone](#clone)
- [copy](#copy)
- [create](#create)
- [determinant](#determinant)
- [equals](#equals)
- [exactEquals](#exactequals)
- [frob](#frob)
- [fromMat2d](#frommat2d)
- [fromMat4](#frommat4)
- [fromQuat](#fromquat)
- [fromRotation](#fromrotation)
- [fromScaling](#fromscaling)
- [fromTranslation](#fromtranslation)
- [fromValues](#fromvalues)
- [identity](#identity)
- [invert](#invert)
- [multiply](#multiply)
- [multiplyScalar](#multiplyscalar)
- [multiplyScalarAndAdd](#multiplyscalarandadd)
- [normalFromMat4](#normalfrommat4)
- [rotate](#rotate)
- [scale](#scale)
- [set](#set)
- [str](#str)
- [subtract](#subtract)
- [translate](#translate)
- [transpose](#transpose)

### Type aliases

#### valueType

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

### Functions

#### add

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

Adds two mat3's

##### Parameters

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

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

out

___

#### adjoint

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

Calculates the adjugate of a mat3

##### Parameters

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

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

out

___

#### clone

▸ **clone**(`a`: [*mat3type*](#mat3type)): [*mat3type*](#mat3type)

Creates a new mat3 initialized with values from an existing matrix

##### Parameters

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

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

a new 3x3 matrix

___

#### copy

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

Copy the values from one mat3 to another

##### Parameters

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

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

out

___

#### create

▸ **create**(): [*mat3type*](#mat3type)

Creates a new identity mat3

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

a new 3x3 matrix

___

#### determinant

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

Calculates the determinant of a mat3

##### Parameters

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

**Returns:** *number*

determinant of a

___

#### equals

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

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

##### Parameters

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

**Returns:** *boolean*

True if the matrices are equal, false otherwise.

___

#### exactEquals

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

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

##### Parameters

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

**Returns:** *boolean*

True if the matrices are equal, false otherwise.

___

#### frob

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

Returns Frobenius norm of a mat3

##### Parameters

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

**Returns:** *number*

Frobenius norm

___

#### fromMat2d

▸ **fromMat2d**(`out`: [*mat3type*](#mat3type), `a`: [*mat2dtype*](#mat2dtype)): [*mat3type*](#mat3type)

Copies the values from a mat2d into a mat3

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | the receiving matrix |
| `a` | [*mat2dtype*](#mat2dtype) | the matrix to copy |

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

out

___

#### fromMat4

▸ **fromMat4**(`out`: [*mat3type*](#mat3type), `a`: [*mat3type*](#mat3type)): [*mat3type*](#mat3type)

Copies the upper-left 3x3 values into the given mat3.

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | the receiving 3x3 matrix |
| `a` | [*mat3type*](#mat3type) | the source 4x4 matrix |

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

out

___

#### fromQuat

▸ **fromQuat**(`out`: [*mat3type*](#mat3type), `q`: [*quattype*](#quattype)): [*mat3type*](#mat3type)

Calculates a 3x3 matrix from the given quaternion

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | mat3 receiving operation result |
| `q` | [*quattype*](#quattype) | Quaternion to create matrix from |

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

out

___

#### fromRotation

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

Creates a matrix from a given angle
This is equivalent to (but much faster than):

    mat3.identity(dest);
    mat3.rotate(dest, dest, rad);

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | mat3 receiving operation result |
| `rad` | *number* | the angle to rotate the matrix by |

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

out

___

#### fromScaling

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

Creates a matrix from a vector scaling
This is equivalent to (but much faster than):

    mat3.identity(dest);
    mat3.scale(dest, dest, vec);

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | mat3 receiving operation result |
| `v` | [*vec2type*](#vec2type) | Scaling vector |

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

out

___

#### fromTranslation

▸ **fromTranslation**(`out`: [*mat3type*](#mat3type), `v`: [*vec2type*](#vec2type)): [*mat3type*](#mat3type)

Creates a matrix from a vector translation
This is equivalent to (but much faster than):

    mat3.identity(dest);
    mat3.translate(dest, dest, vec);

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | mat3 receiving operation result |
| `v` | [*vec2type*](#vec2type) | Translation vector |

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

out

___

#### fromValues

▸ **fromValues**(`m00`: *number*, `m01`: *number*, `m02`: *number*, `m10`: *number*, `m11`: *number*, `m12`: *number*, `m20`: *number*, `m21`: *number*, `m22`: *number*): [*mat3type*](#mat3type)

Create a new mat3 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) |
| `m02` | *number* | Component in column 0, row 2 position (index 2) |
| `m10` | *number* | Component in column 1, row 0 position (index 3) |
| `m11` | *number* | Component in column 1, row 1 position (index 4) |
| `m12` | *number* | Component in column 1, row 2 position (index 5) |
| `m20` | *number* | Component in column 2, row 0 position (index 6) |
| `m21` | *number* | Component in column 2, row 1 position (index 7) |
| `m22` | *number* | Component in column 2, row 2 position (index 8) |

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

A new mat3

___

#### identity

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

Set a mat3 to the identity matrix

##### Parameters

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

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

out

___

#### invert

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

Inverts a mat3

##### Parameters

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

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

out

___

#### multiply

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

Multiplies two mat3's

##### Parameters

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

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

out

___

#### multiplyScalar

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

Multiply each element of the matrix by a scalar.

##### Parameters

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

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

out

___

#### multiplyScalarAndAdd

▸ **multiplyScalarAndAdd**(`out`: [*mat3type*](#mat3type), `a`: [*mat3type*](#mat3type), `b`: [*mat3type*](#mat3type), `s`: *number*): [*mat3type*](#mat3type)

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

##### Parameters

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

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

out

___

#### normalFromMat4

▸ **normalFromMat4**(`out`: [*mat3type*](#mat3type), `a`: [*mat4type*](#mat4type)): [*mat3type*](#mat3type) \| ``null``

Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | mat3 receiving operation result |
| `a` | [*mat4type*](#mat4type) | Mat4 to derive the normal matrix from |

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

out

___

#### rotate

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

Rotates a mat3 by the given angle

##### Parameters

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

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

out

___

#### scale

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

Scales the mat3 by the dimensions in the given vec2

##### Parameters

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

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

out

___

#### set

▸ **set**(`out`: [*mat3type*](#mat3type), `m00`: *number*, `m01`: *number*, `m02`: *number*, `m10`: *number*, `m11`: *number*, `m12`: *number*, `m20`: *number*, `m21`: *number*, `m22`: *number*): [*mat3type*](#mat3type)

Set the components of a mat3 to the given values

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | 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) |
| `m02` | *number* | Component in column 0, row 2 position (index 2) |
| `m10` | *number* | Component in column 1, row 0 position (index 3) |
| `m11` | *number* | Component in column 1, row 1 position (index 4) |
| `m12` | *number* | Component in column 1, row 2 position (index 5) |
| `m20` | *number* | Component in column 2, row 0 position (index 6) |
| `m21` | *number* | Component in column 2, row 1 position (index 7) |
| `m22` | *number* | Component in column 2, row 2 position (index 8) |

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

out

___

#### str

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

Returns a string representation of a mat3

##### Parameters

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

**Returns:** *string*

string representation of the matrix

___

#### subtract

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

Subtracts matrix b from matrix a

##### Parameters

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

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

out

___

#### translate

▸ **translate**(`out`: [*mat3type*](#mat3type), `a`: [*mat3type*](#mat3type), `v`: [*vec2type*](#vec2type)): [*mat3type*](#mat3type)

Translate a mat3 by the given vector

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `out` | [*mat3type*](#mat3type) | the receiving matrix |
| `a` | [*mat3type*](#mat3type) | the matrix to translate |
| `v` | [*vec2type*](#vec2type) | vector to translate by |

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

out

___

#### transpose

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

Transpose the values of a mat3

##### Parameters

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

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

out


<a name="modulesmat4md"></a>

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