123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- <h1>[name]</h1>
- <div class="desc">A class representing a 4x4 [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].</div>
- <h2>Example</h2>
- <code>// 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 );
- </code>
- <h2>Constructor</h2>
- <h3>[name]()</h3>
- <div>
- Creates and initializes the [name] to the 4x4
- [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
- </div>
- <h2>Properties</h2>
- <h3>[property:Float32Array elements]</h3>
- <div>
- A [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]
- list of matrix values.
- </div>
- <h3>[property:Boolean isMatrix4]</h3>
- <div>
- Used to check whether this or derived classes are Matrix4s. Default is *true*.<br /><br />
- You should not change this, as it used internally for optimisation.
- </div>
- <h2>Methods</h2>
- <h3>[method:Array applyToBuffer]( [page:ArrayBuffer buffer], [page:Number offset], [page:Number length] )</h3>
- <div>
- [page:Array buffer] - An [link:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer ArrayBuffer]
- of floats in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...], that represent 3D vectors.<br />>
- [page:Number offset] - (optional) index in the array of the first vector's x component. Default is 0.<br />
- [page:Number length] - (optional) index in the array of the last vector's z component.
- Default is the last element in the array.<br /><br />
- Multiplies (applies) the upper 3x3 matrix of this matrix to every 3D vector in the [page:ArrayBuffer buffer].
- </div>
- <h3>[method:Array applyToVector3Array]( [page:Array array], [page:Number offset], [page:Number length] )</h3>
- <div>
- [page:Array array] - An array of floats in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...],
- that represent 3D vectors.<br />>
- [page:Number offset] - (optional) index in the array of the first vector's x component. Default is 0.<br />
- [page:Number length] - (optional) index in the array of the last vector's z component.
- Default is the last element in the array.<br /><br />
- Multiplies (applies) the upper 3x3 matrix of this matrix to every 3D vector in the [page:Array array].
- </div>
- <h3>[method:Matrix4 clone]()</h3>
- <div>Creates a new Matrix4 and with identical elements to this one.</div>
- <h3>[method:Matrix4 compose]( [page:Vector3 translation], [page:Quaternion quaternion], [page:Vector3 scale] )</h3>
- <div>
- Sets this matrix to the transformation composed of [page:Vector3 translation], [page:Quaternion quaternion] and [page:Vector3 scale].
- </div>
- <h3>[method:Matrix4 copy]( [page:Matrix4 m] )</h3>
- <div>Copies the elements of matrix [page:Matrix4 m] into this matrix.</div>
- <h3>[method:Matrix4 copyPosition]( [page:Matrix4 m] )</h3>
- <div>
- Copies the translation component of the supplied matrix *m* into this matrix's translation component.
- </div>
- <h3>[method:null decompose]( [page:Vector3 translation], [page:Quaternion quaternion], [page:Vector3 scale] )</h3>
- <div>
- Decomposes this matrix into the *translation*, *quaternion* and *scale* components.
- </div>
- <h3>[method:Float determinant]()</h3>
- <div>
- Computes and returns the determinant of this matrix.<br />
- Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm]
- </div>
- <h3>[method:Boolean equals]( [page:Matrix4 m] )</h3>
- <div>Return true if this and [page:Matrix4 m] are equals.</div>
- <h3>[method:Matrix4 extractBasis]( [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] )</h3>
- <div>
- Extracts basis of into the three axis vectors provided. Returns the current matrix.
- </div>
- <h3>[method:Matrix4 extractRotation]( [page:Matrix4 m] )</h3>
- <div>
- Extracts the rotation of the supplied matrix *m* into this matrix rotation component.
- </div>
- <h3>[method:Matrix4 fromArray]( [page:Array array], [page:Integer offset] )</h3>
- <div>
- array -- [page:Array] The array to read the elements from.<br />
- offset -- [page:Integer] optional offset into the array. Default is 0.
- </div>
- <div>
- Sets the elements of this matrix based on an array in column-major format.
- </div>
- <h3>[method:Matrix4 getInverse]( [page:Matrix4 m] )</h3>
- <div>
- Sets this matrix to the inverse of matrix *m*.<br />
- Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm].
- </div>
- <h3>[method:Float getMaxScaleOnAxis]()</h3>
- <div>
- Gets the maximum scale value of the 3 axes.
- </div>
- <h3>[method:Matrix4 identity]()</h3>
- <div>
- Resets this matrix to identity.
- </div>
- <h3>[method:Matrix4 lookAt]( [page:Vector3 eye], [page:Vector3 center], [page:Vector3 up], )</h3>
- <div>
- Constructs a rotation matrix, looking from *eye* towards *center* with defined *up* vector.
- </div>
- <h3>[method:Matrix4 makeRotationAxis]( [page:Vector3 axis], [page:Float theta] )</h3>
- <div>
- axis — Rotation axis, should be normalized.
- theta — Rotation angle in radians.
- </div>
- <div>
- Sets this matrix as rotation transform around *axis* by *angle* radians.<br />
- Based on [link:http://www.gamedev.net/reference/articles/article1199.asp].
- </div>
- <h3>[method:Matrix4 makeBasis]( [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] )</h3>
- <div>
- Creates the basis matrix consisting of the three provided axis vectors. Returns the current matrix.
- </div>
- <h3>[method:Matrix4 makeFrustum]( [page:Float left], [page:Float right], [page:Float bottom], [page:Float top], [page:Float near], [page:Float far] )</h3>
- <div>
- Creates a [page:Frustum frustum] matrix.
- </div>
- <h3>[method:Matrix4 makeOrthographic]( [page:Float left], [page:Float right], [page:Float top], [page:Float bottom], [page:Float near], [page:Float far] )</h3>
- <div>
- Creates an orthographic projection matrix.
- </div>
- <h3>[method:Matrix4 makePerspective]( [page:Float fov], [page:Float aspect], [page:Float near], [page:Float far] )</h3>
- <div>
- Creates a perspective projection matrix.
- </div>
- <h3>[method:Matrix4 makeRotationFromEuler]( [page:Euler euler] )</h3>
- <div>
- euler — Rotation vector followed by order of rotations, e.g., "XYZ".
- </div>
- <div>
- Sets the rotation submatrix of this matrix to the rotation specified by Euler angles, the rest of the matrix is identity.<br />
- Default order is *"XYZ"*.
- </div>
- <h3>[method:Matrix4 makeRotationFromQuaternion]( [page:Quaternion q] )</h3>
- <div>
- Sets the rotation submatrix of this matrix to the rotation specified by *q*. The rest of the matrix is identity.
- </div>
- <h3>[method:Matrix4 makeRotationX]( [page:Float theta] )</h3>
- <div>
- theta — Rotation angle in radians.
- </div>
- <div>
- Sets this matrix as rotation transform around x axis by *theta* radians.
- </div>
- <h3>[method:Matrix4 makeRotationY]( [page:Float theta] )</h3>
- <div>
- theta — Rotation angle in radians.
- </div>
- <div>
- Sets this matrix as rotation transform around y axis by *theta* radians.
- </div>
- <h3>[method:Matrix4 makeRotationZ]( [page:Float theta] )</h3>
- <div>
- theta — Rotation angle in radians.
- </div>
- <div>
- Sets this matrix as rotation transform around z axis by *theta* radians.
- </div>
- <h3>[method:Matrix4 makeScale]( [page:Float x], [page:Float y], [page:Float z] )</h3>
- <div>
- Sets this matrix as scale transform.
- </div>
- <h3>[method:Matrix4 makeShear]( [page:Float x], [page:Float y], [page:Float z] )</h3>
- <div>
- Sets this matrix as shear transform.
- </div>
- <h3>[method:Matrix4 makeTranslation]( [page:Float x], [page:Float y], [page:Float z] )</h3>
- <div>
- Sets this matrix as translation transform.
- </div>
- <h3>[method:Matrix4 multiply]( [page:Matrix4 m] )</h3>
- <div>
- Post-multiplies this matrix by *m*.
- </div>
- <h3>[method:Matrix4 multiplyMatrices]( [page:Matrix4 a], [page:Matrix4 b] )</h3>
- <div>
- Sets this matrix to *a x b*.
- </div>
- <h3>[method:Matrix4 multiplyScalar]( [page:Float s] )</h3>
- <div>
- Multiplies every component of the matrix by a scalar value *s*.
- </div>
- <h3>[method:Matrix4 multiplyToArray]( [page:Matrix4 a], [page:Matrix4 b], [page:Array r] )</h3>
- <div>
- Sets this matrix to *a x b* and stores the result into the flat array *r*.<br />
- *r* can be either a regular Array or a TypedArray.
- </div>
- <h3>[method:Matrix4 premultiply]( [page:Matrix4 m] )</h3>
- <div>
- Pre-multiplies this matrix by *m*.
- </div>
- <h3>[method:Matrix4 scale]( [page:Vector3 v] )</h3>
- <div>
- Multiplies the columns of this matrix by vector *v*.
- </div>
- <h3>[method:Matrix4 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] )</h3>
- <div>
- Sets all fields of this matrix to the supplied row-major values n11..n44.
- </div>
- <h3>[method:Matrix4 setPosition]( [page:Vector3 v] )</h3>
- <div>
- Sets the position component for this matrix from vector *v*.
- </div>
- <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] )</h3>
- <div>
- array -- [page:Array] optional array to store the vector <br />
- offset -- [page:Integer] optional offset into the array
- </div>
- <div>
- Writes the elements of this matrix to an array in column-major format.
- </div>
- <h3>[method:Matrix4 transpose]()</h3>
- <div>
- Transposes this matrix.
- </div>
- <h2>Source</h2>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
- </html>
|