Capítulo 356 de 859

Chapter 356: Matrix2

Core Idea

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:

const m = new THREE.Matrix2();
m.set( 11, 12,
       21, 22 );

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.

Key Concepts

  • elements : Array.<number>: A column-major list of matrix values.

Reference Tables

Constructor

Signature
new Matrix2( n11 : number, n12 : number, n21 : number, n22 : number )

Properties

PropertyDescription
.elements : Array.<number>A column-major list of matrix values.

Methods

MethodDescription
.fromArray( array : Array.<number>, offset : number ) : Matrix2Sets the elements of the matrix from the given array.
.identity() : Matrix2Sets this matrix to the 2x2 identity matrix.
.set( n11 : number, n12 : number, n21 : number, n22 : number ) : Matrix2Sets the elements of the matrix.The arguments are supposed to be in row-major order.

Key Takeaways

  1. Most relevant properties: elements.
  2. Key methods: fromArray, identity, set.

Connects To