# [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] )

## 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 sets result into flat array *r*.
Destination array can be regular Array or 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]

### .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.

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

Sets this matrix as translation transform.

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

Sets this matrix as scale transform.

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

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

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

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

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

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

### .setRotationAxis( [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].

### .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 internal class vector, make copy or clone 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 internal class vector, make copy or clone 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 internal class vector, make copy or clone 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 internal class vector, make copy or clone if you don't use it right away.

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

Sets this matrix to 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 rotation submatrix of this matrix to rotation specified by Euler angles.
Default order "XYZ".

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

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

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

Multiplies columns of this matrix by vector *v*.

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

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

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

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

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

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

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

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

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

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

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

Rotates this matrix around x axis by *angle*.

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

Rotates this matrix around y axis by *angle*.

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

Rotates this matrix around z axis by *angle*.

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

Translates this matrix by vector *v*.

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

Clones this matrix.

## Static methods

### .makeInvert3x3( [page:Matrix4 m] ) [page:Matrix3]

Inverts just rotation submatrix of matrix *m*.
Note: this method returns a reference to internal 3x3 matrix, make copy or clone if you don't use it right away.
Based on [link:http://code.google.com/p/webgl-mjs/].

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

Creates frustum matrix.

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

Creates perspective projection matrix.

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

Creates orthographic projection matrix.

## Source

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