File: Matrix2.md | Updated: 11/15/2025
Represents a 2x2 matrix.
A Note on Row-Major and Column-Major Ordering:
The constructor and Matrix2#set method take arguments in row-major order, while internally they are stored in the Matrix2#elements array in column-major order. This means that calling:
will result in the elements array containing:
m.elements = [ 11, 21,
12, 22 ];
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 transpose of any matrices outlined here to make sense of the calculations.
const m = new THREE.Matrix2();
m.set( 11, 12,
21, 22 );
Constructs a new 2x2 matrix. The arguments are supposed to be in row-major order. If no arguments are provided, the constructor initializes the matrix as an identity matrix.
n11 | 1-1 matrix element.
---|---
n12 | 1-2 matrix element.
n21 | 2-1 matrix element.
n22 | 2-2 matrix element.
A column-major list of matrix values.
This flag can be used for type testing.
Default is true.
Sets the elements of the matrix from the given array.
array | The matrix elements in column-major order.
---|---
offset | Index of the first element in the array. Default is 0.
Returns: A reference to this matrix.
Sets this matrix to the 2x2 identity matrix.
Returns: A reference to this matrix.
Sets the elements of the matrix.The arguments are supposed to be in row-major order.
n11 | 1-1 matrix element.
---|---
n12 | 1-2 matrix element.
n21 | 2-1 matrix element.
n22 | 2-2 matrix element.
Returns: A reference to this matrix.