# [name]

A class representing a 3x3 [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].

## Example

`var m = new Matrix3();`

## A Note on Row-Major and Column-Major Ordering

The [page:set]() method takes arguments in [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major] order, while internally they are stored in the [page:.elements elements] array in column-major order.
This means that calling `m.set( 11, 12, 13, 21, 22, 23, 31, 32, 33 );` will result in the [page:.elements elements] array containing: `m.elements = [ 11, 21, 31, 12, 22, 32, 13, 23, 33 ];` and internally all calculations are performed using column-major ordering. However, as the actual ordering makes no difference mathematically and most people are used to thinking about matrices in row-major order, the three.js documentation shows matrices in row-major order. Just bear in mind that if you are reading the source code, you'll have to take the [link:https://en.wikipedia.org/wiki/Transpose transpose] of any matrices outlined here to make sense of the calculations.

## Constructor

### [name]()

Creates and initializes the [name] to the 3x3 [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].

## Properties

### [property:Array elements]

A [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major] list of matrix values.

### [property:Boolean isMatrix3]

Used to check whether this or derived classes are Matrix3s. Default is *true*.
You should not change this, as it used internally for optimisation.

## Methods

### [method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )

[page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.
Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute].

### [method:Matrix3 clone]()

Creates a new Matrix3 and with identical elements to this one.

### [method:this copy]( [param:Matrix3 m] )

Copies the elements of matrix [page:Matrix3 m] into this matrix.

### [method:Float determinant]()

Computes and returns the [link:https://en.wikipedia.org/wiki/Determinant determinant] of this matrix.

### [method:Boolean equals]( [param:Matrix3 m] )

Return true if this matrix and [page:Matrix3 m] are equal.

### [method:this fromArray]( [param:Array array], [param:Integer offset] )

[page:Array array] - the array to read the elements from.
[page:Integer offset] - (optional) index of first element in the array. Default is 0.
Sets the elements of this matrix based on an array in [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.

### [method:this getInverse]( [param:Matrix3 m], [param:Boolean throwOnDegenerate] )

[page:Matrix3 m] - the matrix to take the inverse of.
[page:Boolean throwOnDegenerate] - (optional) If true, throw an error if the matrix is degenerate (not invertible).
Set this matrix to the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] of the passed matrix [page:Matrix3 m], using the [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method]. If [page:Boolean throwOnDegenerate] is not set and the matrix is not invertible, set this to the 3x3 identity matrix.

### [method:this getNormalMatrix]( [param:Matrix4 m] )

[page:Matrix4 m] - [page:Matrix4]
Sets this matrix as the upper left 3x3 of the [link:https://en.wikipedia.org/wiki/Normal_matrix normal matrix] of the passed [page:Matrix4 matrix4]. The normal matrix is the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] [link:https://en.wikipedia.org/wiki/Transpose transpose] of the matrix [page:Matrix4 m].

### [method:this identity]()

Resets this matrix to the 3x3 identity matrix: `1, 0, 0 0, 1, 0 0, 0, 1`

### [method:this multiply]( [param:Matrix3 m] )

Post-multiplies this matrix by [page:Matrix3 m].

### [method:this multiplyMatrices]( [param:Matrix3 a], [param:Matrix3 b] )

Sets this matrix to [page:Matrix3 a] x [page:Matrix3 b].

### [method:this multiplyScalar]( [param:Float s] )

Multiplies every component of the matrix by the scalar value *s*.

### [method:this set]( [param:Float n11], [param:Float n12], [param:Float n13], [param:Float n21], [param:Float n22], [param:Float n23], [param:Float n31], [param:Float n32], [param:Float n33] )

[page:Float n11] - value to put in row 1, col 1.
[page:Float n12] - value to put in row 1, col 2.
...
...
[page:Float n32] - value to put in row 3, col 2.
[page:Float n33] - value to put in row 3, col 3.
Sets the 3x3 matrix values to the given [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major] sequence of values.

### [method:this premultiply]( [param:Matrix3 m] )

Pre-multiplies this matrix by [page:Matrix3 m].

### [method:this setFromMatrix4]( [param:Matrix4 m] )

Set this matrx to the upper 3x3 matrix of the Matrix4 [page:Matrix4 m].

### [method:this setUvTransform]( [param:Float tx], [param:Float ty], [param:Float sx], [param:Float sy], [param:Float rotation], [param:Float cx], [param:Float cy] )

[page:Float tx] - offset x
[page:Float ty] - offset y
[page:Float sx] - repeat x
[page:Float sy] - repeat y
[page:Float rotation] - rotation (in radians)
[page:Float cx] - center x of rotation
[page:Float cy] - center y of rotation
Sets the UV transform matrix from offset, repeat, rotation, and center.

### [method:Array toArray]( [param:Array array], [param:Integer offset] )

[page:Array array] - (optional) array to store the resulting vector in. If not given a new array will be created.
[page:Integer offset] - (optional) offset in the array at which to put the result.
Writes the elements of this matrix to an array in [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.

### [method:this transpose]()

[link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix in place.

### [method:this transposeIntoArray]( [param:Array array] )

[page:Array array] - array to store the resulting vector in.
[link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix into the supplied array, and returns itself unchanged.

## Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]