# [name]

A 4x4 Matrix.

## Example

`// 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.setRotationX( alpha ); m2.setRotationY( beta ); m3.setRotationZ( gamma ); m.multiply( m1, m2 ); m.multiplySelf( m3 );`

## Constructor

### [name]( [page:Float n11], [page:Float n12], [page:Float n13], [page:Float n14], [page:Float n21], [page:Float n22], [page:Float n23], [page:Float n24], [page:Float n31], [page:Float n32], [page:Float n33], [page:Float n34], [page:Float n41], [page:Float n42], [page:Float n43], [page:Float n44] )

Initialises the matrix with the supplied n11..n44 values, or just creates an identity matrix if no values are passed.

## Properties

### .[page:Float32Array elements]

## Methods

### .set( [page:Float n11], [page:Float n12], [page:Float n13], [page:Float n14], [page:Float n21], [page:Float n22], [page:Float n23], [page:Float n24], [page:Float n31], [page:Float n32], [page:Float n33], [page:Float n34], [page:Float n41], [page:Float n42], [page:Float n43], [page:Float n44] ) [page:Matrix4]

Sets all fields of this matrix.

### .identity() [page:Matrix4]

Resets this matrix to identity.

### .copy( [page:Matrix4 m] ) [page:Matrix4]

Copies a matrix *m* into this matrix.

### .lookAt( [page:Vector3 eye], [page:Vector3 center], [page:Vector3 up], ) [page:Matrix4]

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

### .multiply( [page:Matrix4 a], [page:Matrix4 b] ) [page:Matrix4]

Sets this matrix to *a x b*.

### .multiplySelf( [page:Matrix4 m] ) [page:Matrix4]

Multiplies this matrix by *m*.

### .multiplyToArray( [page:Matrix4 a], [page:Matrix4 b], [page:Array r] ) [page:Matrix4]

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( [page:Float s] ) [page:Matrix4]

Multiplies this matrix by *s*.

### .multiplyVector3( [page:Vector3 v] ) [page:Vector3]

Applies this matrix to *v*.

### .multiplyVector4( [page:Vector4 v] ) [page:Vector4]

Applies this matrix to *v*.

### .rotateAxis( [page:Vector3 v] ) [page:Vector3]

Applies rotation submatrix of this matrix to vector *v* and then normalizes it.

### .crossVector( [page:Vector4 a] ) [page:Vector4]

Computes the cross product between this matrix and the [page:Vector4] parameter *a*.

### .determinant() [page:Float]

Computes determinant of this matrix.
Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm]

### .transpose() [page:Matrix4]

Transposes this matrix.

### .flatten() [page:Array]

Flattens this matrix into internal [page:Matrix4 Matrix4.flat] array.

### .flattenToArray( [page:Array flat] ) [page:Array]

Flattens this matrix into supplied *flat* array.

### .flattenToArrayOffset( [page:Array flat], [page:Integer offset] ) [page:Array]

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

### .setPosition( [page:Vector3 v] ) [page:Matrix4]

Sets the position component for this matrix from vector *v*.

### .getPosition() [page:Vector3]

Returns position component from this matrix.
Note: this method returns a reference to the internal class vector, make a copy or clone it if you don't use it right away.

### .getColumnX() [page:Vector3]

Returns x column component from this matrix.
Note: this method returns a reference to the internal class vector, make a copy or clone it if you don't use it right away.

### .getColumnY() [page:Vector3]

Returns y column component from this matrix.
Note: this method returns a reference to the internal class vector, make a copy or clone it if you don't use it right away.

### .getColumnZ() [page:Vector3]

Returns z column component from this matrix.
Note: this method returns a reference to the internal class vector, make a copy or clone it if you don't use it right away.

### .getInverse( [page:Matrix4 m] ) [page:Matrix4]

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

### .setRotationFromEuler( [page:Vector3 v], [page:String order] ) [page:Matrix4]

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

### .setRotationFromQuaternion( [page:Quaternion q] ) [page:Matrix4]

Sets the rotation submatrix of this matrix to the rotation specified by *q*.

### .scale( [page:Vector3 v] ) [page:Matrix4]

Multiplies the columns of this matrix by vector *v*.

### .compose( [page:Vector3 translation], [page:Quaternion rotation], [page:Vector3 scale] ) [page:Matrix4]

Sets this matrix to the transformation composed of *translation*, *rotation* and *scale*.

### .decompose( [page:Vector3 translation], [page:Quaternion rotation], [page:Vector3 scale] ) [page:Array]

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

### .extractPosition( [page:Matrix4 m] ) [page:Matrix4]

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

### .extractRotation( [page:Matrix4 m] ) [page:Matrix4]

Copies the rotation component of the supplied matrix *m* into this matrix rotation component.

### .rotateByAxis( [page:Vector3 axis], [page:Float angle] ) [page:Matrix4]

Rotates this matrix around the supplied *axis* by *angle*.

### .rotateX( [page:Float angle] ) [page:Matrix4]

Rotates this matrix around the *x* axis by *angle*.

### .rotateY( [page:Float angle] ) [page:Matrix4]

Rotates this matrix around the *y* axis by *angle*.

### .rotateZ( [page:Float angle] ) [page:Matrix4]

Rotates this matrix around the *z* axis by *angle*.

### .translate( [page:Vector3 v] ) [page:Matrix4]

Translates this matrix by vector *v*.

### .makeTranslation( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4]

Sets this matrix as translation transform.

### .makeRotationX( [page:Float theta] ) [page:Matrix4]

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

### .makeRotationY( [page:Float theta] ) [page:Matrix4]

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

### .makeRotationZ( [page:Float theta] ) [page:Matrix4]

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

### .makeRotationAxis( [page:Vector3 axis], [page:Float theta] ) [page:Matrix4]

axis — Rotation axis. theta — Rotation angle in radians.
Sets this matrix as rotation transform around *axis* by *angle* radians.
Based on [link:http://www.gamedev.net/reference/articles/article1199.asp].

### .makeScale( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4]

Sets this matrix as scale transform.

### .makeFrustum( [page:Float left], [page:Float right], [page:Float bottom], [page:Float top], [page:Float near], [page:Float far] ) [page:Matrix4]

Creates a [page:Frustum frustum] matrix.

### .makePerspective( [page:Float fov], [page:Float aspect], [page:Float near], [page:Float far] ) [page:Matrix4]

Creates a perspective projection matrix.

### .makeOrthographic( [page:Float left], [page:Float right], [page:Float bottom], [page:Float top], [page:Float near], [page:Float far] ) [page:Matrix4]

Creates an orthographic projection matrix.

### .clone() [page:Matrix4]

Clones this matrix.

## Source

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