123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <h1>[name]</h1>
- <div class="desc">A 4x4 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.setRotationX( alpha );
- m2.setRotationY( beta );
- m3.setRotationZ( gamma );
- m.multiply( m1, m2 );
- m.multiplySelf( m3 );
- </code>
- <h2>Constructor</h2>
- <h3>[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] )</h3>
- <h2>Properties</h2>
- <h3>.[page:Float n11]</h3>
- <h3>.[page:Float n12]</h3>
- <h3>.[page:Float n13]</h3>
- <h3>.[page:Float n14]</h3>
- <h3>.[page:Float n21]</h3>
- <h3>.[page:Float n22]</h3>
- <h3>.[page:Float n23]</h3>
- <h3>.[page:Float n24]</h3>
- <h3>.[page:Float n31]</h3>
- <h3>.[page:Float n32]</h3>
- <h3>.[page:Float n33]</h3>
- <h3>.[page:Float n34]</h3>
- <h3>.[page:Float n41]</h3>
- <h3>.[page:Float n42]</h3>
- <h3>.[page:Float n43]</h3>
- <h3>.[page:Float n44]</h3>
- <h2>Methods</h2>
- <h3>.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]</h3>
- <div>
- Sets all fields of this matrix.
- </div>
- <h3>.identity() [page:Matrix4]</h3>
- <div>
- Resets this matrix to identity.
- </div>
- <h3>.copy( [page:Matrix4 m] ) [page:Matrix4]</h3>
- <div>
- Copies a matrix <strong>m</strong> into this matrix.
- </div>
- <h3>.lookAt( [page:Vector3 eye], [page:Vector3 center], [page:Vector3 up], ) [page:Matrix4]</h3>
- <div>
- Constructs a rotation matrix, looking from <strong>eye</strong> towards <strong>center</strong> with defined <strong>up</strong> vector.
- </div>
- <h3>.multiply( [page:Matrix4 a], [page:Matrix4 b] ) [page:Matrix4]</h3>
- <div>
- Sets this matrix to <strong>a * b</strong>.
- </div>
- <h3>.multiplySelf( [page:Matrix4 m] ) [page:Matrix4]</h3>
- <div>
- Multiplies this matrix by <strong>m</strong>.
- </div>
- <h3>.multiplyToArray( [page:Matrix4 a], [page:Matrix4 b], [page:Array r] ) [page:Matrix4]</h3>
- <div>
- Sets this matrix to <strong>a * b</strong> and sets result into flat array <strong>r</strong>.<br />
- Destination array can be regular Array or TypedArray.
- </div>
- <h3>.multiplyScalar( [page:Float s] ) [page:Matrix4]</h3>
- <div>
- Multiplies this matrix by <strong>s</strong>.
- </div>
- <h3>.multiplyVector3( [page:Vector3 v] ) [page:Vector3]</h3>
- <div>
- Applies this matrix to <strong>v</strong>.
- </div>
- <h3>.multiplyVector4( [page:Vector4 v] ) [page:Vector4]</h3>
- <div>
- Applies this matrix to <strong>v</strong>.
- </div>
- <h3>.rotateAxis( [page:Vector3 v] ) [page:Vector3]</h3>
- <div>
- Applies rotation submatrix of this matrix to vector <strong>v</strong> and then normalizes it.
- </div>
- <h3>.crossVector( [page:Vector4 a] ) [page:Vector4]</h3>
- <h3>.determinant() [page:Float]</h3>
- <div>
- Computes determinant of this matrix.<br />
- Based on <a href="http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm">http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm</a>
- </div>
- <h3>.transpose() [page:Matrix4]</h3>
- <div>
- Transposes this matrix.
- </div>
- <h3>.flatten() [page:Array]</h3>
- <div>
- Flattens this matrix into internal [page:Matrix4 Matrix4.flat] array.
- </div>
- <h3>.flattenToArray( [page:Array flat] ) [page:Array]</h3>
- <div>
- Flattens this matrix into supplied <strong>flat</strong> array.
- </div>
- <h3>.flattenToArrayOffset( [page:Array flat], [page:Integer offset] ) [page:Array]</h3>
- <div>
- Flattens this matrix into supplied <strong>flat</strong> array starting from <strong>offset</strong> position in the array.
- </div>
- <h3>.setTranslation( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4]</h3>
- <div>
- Sets this matrix as translation transform.
- </div>
- <h3>.setScale( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4]</h3>
- <div>
- Sets this matrix as scale transform.
- </div>
- <h3>.setRotationX( [page:Float theta] ) [page:Matrix4]</h3>
- <div>
- theta — Rotation angle in radians.
- </div>
- <div>
- Sets this matrix as rotation transform around x axis by <strong>theta</strong> radians.
- </div>
- <h3>.setRotationY( [page:Float theta] ) [page:Matrix4]</h3>
- <div>
- theta — Rotation angle in radians.
- </div>
- <div>
- Sets this matrix as rotation transform around y axis by <strong>theta</strong> radians.
- </div>
- <h3>.setRotationZ( [page:Float theta] ) [page:Matrix4]</h3>
- <div>
- theta — Rotation angle in radians.
- </div>
- <div>
- Sets this matrix as rotation transform around z axis by <strong>theta</strong> radians.
- </div>
- <h3>.setRotationAxis( [page:Vector3 axis], [page:Float theta] ) [page:Matrix4]</h3>
- <div>
- axis — Rotation axis.
- theta — Rotation angle in radians.
- </div>
- <div>
- Sets this matrix as rotation transform around <strong>axis</strong> by <strong>angle</strong> radians.<br />
- Based on <a href="http://www.gamedev.net/reference/articles/article1199.asp">http://www.gamedev.net/reference/articles/article1199.asp</a>.
- </div>
- <h3>.setPosition( [page:Vector3 v] ) [page:Matrix4]</h3>
- <div>
- Sets the position component for this matrix from vector <strong>v</strong>.
- </div>
- <h3>.getPosition() [page:Vector3]</h3>
- <div>
- Returns position component from this matrix.<br />
- Note: this method returns a reference to internal class vector, make copy or clone if you don't use it right away.
- </div>
- <h3>.getColumnX() [page:Vector3]</h3>
- <div>
- Returns x column component from this matrix.<br />
- Note: this method returns a reference to internal class vector, make copy or clone if you don't use it right away.
- </div>
- <h3>.getColumnY() [page:Vector3]</h3>
- <div>
- Returns y column component from this matrix.<br />
- Note: this method returns a reference to internal class vector, make copy or clone if you don't use it right away.
- </div>
- <h3>.getColumnZ() [page:Vector3]</h3>
- <div>
- Returns z column component from this matrix.<br />
- Note: this method returns a reference to internal class vector, make copy or clone if you don't use it right away.
- </div>
- <h3>.getInverse( [page:Matrix4 m] ) [page:Matrix4]</h3>
- <div>
- Sets this matrix to inverse of matrix <strong>m</strong>.<br />
- Based on <a href="http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm">http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm</a>.
- </div>
- <h3>.setRotationFromEuler( [page:Vector3 v], [page:String order] ) [page:Matrix4]</h3>
- <div>
- v — Rotation vector.
- order — The order of rotations. Eg. "XYZ".
- </div>
- <div>
- Sets rotation submatrix of this matrix to rotation specified by Euler angles.<br />
- Default order "XYZ".
- </div>
- <h3>.setRotationFromQuaternion( [page:Quaternion q] ) [page:Matrix4]</h3>
- <div>
- Sets rotation submatrix of this matrix to rotation specified by <strong>q</strong>.
- </div>
- <h3>.scale( [page:Vector3 v] ) [page:Matrix4]</h3>
- <div>
- Multiplies columns of this matrix by vector <strong>v</strong>.
- </div>
- <h3>.compose( [page:Vector3 translation], [page:Quaternion rotation], [page:Vector3 scale] ) [page:Matrix4]</h3>
- <div>
- Sets this matrix to transform composed of <strong>translation</strong>, <strong>rotation</strong> and <strong>scale</strong>.
- </div>
- <h3>.decompose( [page:Vector3 translation], [page:Quaternion rotation], [page:Vector3 scale] ) [page:Array]</h3>
- <div>
- Decomposes this matrix into <strong>translation</strong>, <strong>rotation</strong> and <strong>scale</strong> components.<br />
- If parameters are not supplied, new instances will be created.
- </div>
- <h2>Source</h2>
- <a href="https://github.com/mrdoob/three.js/blob/master/src/[path].js" target="_blank">src/[path].js</a>
|