[name]

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

Code Example

const m = new Matrix2();

A Note on Row-Major and Column-Major Ordering

The constructor and [page:set]() method take 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, 21, 22 ); will result in the [page:.elements 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 [link:https://en.wikipedia.org/wiki/Transpose transpose] of any matrices outlined here to make sense of the calculations.

Constructor

[name]( [param:Number n11], [param:Number n12], [param:Number n21], [param:Number n22] )

Creates a 2x2 matrix with the given arguments in row-major order. If no arguments are provided, the constructor 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.

Methods

[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 identity]()

Resets this matrix to the 2x2 identity matrix:

[ 1 0 0 1 ]

[method:this set]( [param:Float n11], [param:Float n12], [param:Float n21], [param:Float n22] )

Sets the 2x2 matrix values to the given [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major] sequence of values:

[ n11 n12 n21 n22 ]

Source

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