Matrix4

Overview

A 4x4 Matrix.

 

 

Constructor

Matrix4( n11n12n13n14n21n22n23n24n31n32n33n34n41n42n43n44 )

Initialises the matrix with the supplied row-major values n11..n44, or just creates an identity matrix if no values are passed.
// Simple rig for rotating around 3 axes

var m = new THREE.Matrix4();

var m1 = new THREE.Matrix4();
var m2 = new THREE.Matrix4();
var m3 = new THREE.Matrix4();

var alpha = 0;
var beta = Math.PI;
var gamma = Math.PI/2;

m1.makeRotationX( alpha );
m2.makeRotationY( beta );
m3.makeRotationZ( gamma );

m.multiplyMatrices( m1, m2 );
m.multiply( m3 );

Properties

.elements

A column-major list of matrix values.

Methods

.set( n11n12n13n14n21n22n23n24n31n32n33n34n41n42n43n44 ) this

Sets all fields of this matrix to the supplied row-major values n11..n44.

.identity() this

Resets this matrix to identity.

.copy( m ) this

Copies a matrix m into this matrix.

.copyPosition( m ) this

Copies the translation component of the supplied matrix m into this matrix translation component.

.extractRotation( m ) this

Extracts the rotation of the supplied matrix m into this matrix rotation component.

.lookAt( eyecenterup, ) this

Constructs a rotation matrix, looking from eye towards center with defined up vector.

.multiply( m ) this

Multiplies this matrix by m.

.multiplyMatrices( ab ) this

Sets this matrix to a x b.

.multiplyToArray( abr ) this

Sets this matrix to a x b and stores the result into the flat array r.
r can be either a regular Array or a TypedArray.

.multiplyScalar( s ) this

Multiplies this matrix by s.

.determinant() Float

.transpose() this

Transposes this matrix.

.flattenToArray( flat ) Array

Flattens this matrix into supplied flat array.

.flattenToArrayOffset( flatoffset ) Array

Flattens this matrix into supplied flat array starting from offset position in the array.

.setPosition( v ) this

Sets the position component for this matrix from vector v.

.getInverse( m ) this

Sets this matrix to the inverse of matrix m.
Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm.

.makeRotationFromEuler( vorder ) this

v — Rotation vector. order — The order of rotations. Eg. "XYZ".
Sets the rotation submatrix of this matrix to the rotation specified by Euler angles, the rest of the matrix is identity.
Default order is "XYZ".

.makeRotationFromQuaternion( q ) this

Sets the rotation submatrix of this matrix to the rotation specified by q. The rest of the matrix is identity.

.scale( v ) this

Multiplies the columns of this matrix by vector v.

.compose( translationquaternionscale ) this

Sets this matrix to the transformation composed of translationquaternion and scale.

.decompose( translationquaternionscale ) Array

Decomposes this matrix into the translationquaternion and scale components.
If parameters are not passed, new instances will be created.

.makeTranslation( xyz ) this

Sets this matrix as translation transform.

.makeRotationX( theta ) this

theta — Rotation angle in radians.
Sets this matrix as rotation transform around x axis by theta radians.

.makeRotationY( theta ) this

theta — Rotation angle in radians.
Sets this matrix as rotation transform around y axis by theta radians.

.makeRotationZ( theta ) this

theta — Rotation angle in radians.
Sets this matrix as rotation transform around z axis by theta radians.

.makeRotationAxis( axistheta ) this

axis — Rotation axis, should be normalized. theta — Rotation angle in radians.
Sets this matrix as rotation transform around axis by angle radians.
Based on http://www.gamedev.net/reference/articles/article1199.asp.

.makeScale( xyz ) this

Sets this matrix as scale transform.

.makeFrustum( leftrightbottomtopnearfar ) this

Creates a frustum matrix.

.makePerspective( fovaspectnearfar ) this

Creates a perspective projection matrix.

.makeOrthographic( leftrightbottomtopnearfar ) this

Creates an orthographic projection matrix.

.clone() Matrix4

Clones this matrix.

.multiplyVector3Array(aArray

array -- An array in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...]
Multiply (apply) this matrix against every vector3 in the array.

.getMaxScaleOnAxis() Float

Gets the max scale value of the 3 axes.

Source

src/math/Matrix4.js