Matrix4.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <div class="desc">A 4x4 Matrix.</div>
  13. <h2>Example</h2>
  14. <code>// Simple rig for rotating around 3 axes
  15. var m = new THREE.Matrix4();
  16. var m1 = new THREE.Matrix4();
  17. var m2 = new THREE.Matrix4();
  18. var m3 = new THREE.Matrix4();
  19. var alpha = 0;
  20. var beta = Math.PI;
  21. var gamma = Math.PI/2;
  22. m1.makeRotationX( alpha );
  23. m2.makeRotationY( beta );
  24. m3.makeRotationZ( gamma );
  25. m.multiplyMatrices( m1, m2 );
  26. m.multiply( m3 );
  27. </code>
  28. <h2>Constructor</h2>
  29. <h3>[name]()</h3>
  30. <div>
  31. Creates and initializes the matrix to the identity matrix.
  32. </div>
  33. <h2>Properties</h2>
  34. <h3>[property:Float32Array elements]</h3>
  35. <div>A column-major list of matrix values.</div>
  36. <h2>Methods</h2>
  37. <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] ) [page:Matrix4 this]</h3>
  38. <div>
  39. Sets all fields of this matrix to the supplied row-major values n11..n44.
  40. </div>
  41. <h3>[method:Matrix4 identity]() [page:Matrix4 this]</h3>
  42. <div>
  43. Resets this matrix to identity.
  44. </div>
  45. <h3>[method:Matrix4 copy]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
  46. <div>
  47. Copies the values of matrix *m* into this matrix.
  48. </div>
  49. <h3>[method:Matrix4 fromArray]( [page:Array array], [page:Integer offset] ) [page:Matrix4 this]</h3>
  50. <div>
  51. array -- [page:Array] The array to read the elements from.<br />
  52. offset -- [page:Integer] optional offset into the array. Default is 0.
  53. </div>
  54. <div>
  55. Sets the elements of this matrix based on an array in column-major format.
  56. </div>
  57. <h3>[method:Matrix4 copyPosition]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
  58. <div>
  59. Copies the translation component of the supplied matrix *m* into this matrix translation component.
  60. </div>
  61. <h3>[method:Matrix4 makeBasis]( [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] ) [page:Matrix4 this]</h3>
  62. <div>
  63. Creates the basis matrix consisting of the three provided axis vectors. Returns the current matrix.
  64. </div>
  65. <h3>[method:Matrix4 extractBasis]( [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] ) [page:Matrix4 this]</h3>
  66. <div>
  67. Extracts basis of into the three axis vectors provided. Returns the current matrix.
  68. </div>
  69. <h3>[method:Matrix4 extractRotation]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
  70. <div>
  71. Extracts the rotation of the supplied matrix *m* into this matrix rotation component.
  72. </div>
  73. <h3>[method:Matrix4 lookAt]( [page:Vector3 eye], [page:Vector3 center], [page:Vector3 up], ) [page:Matrix4 this]</h3>
  74. <div>
  75. Constructs a rotation matrix, looking from *eye* towards *center* with defined *up* vector.
  76. </div>
  77. <h3>[method:Matrix4 multiply]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
  78. <div>
  79. Post-multiplies this matrix by *m*.
  80. </div>
  81. <h3>[method:Matrix4 premultiply]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
  82. <div>
  83. Pre-multiplies this matrix by *m*.
  84. </div>
  85. <h3>[method:Matrix4 multiplyMatrices]( [page:Matrix4 a], [page:Matrix4 b] ) [page:Matrix4 this]</h3>
  86. <div>
  87. Sets this matrix to *a x b*.
  88. </div>
  89. <h3>[method:Matrix4 multiplyToArray]( [page:Matrix4 a], [page:Matrix4 b], [page:Array r] ) [page:Matrix4 this]</h3>
  90. <div>
  91. Sets this matrix to *a x b* and stores the result into the flat array *r*.<br />
  92. *r* can be either a regular Array or a TypedArray.
  93. </div>
  94. <h3>[method:Matrix4 multiplyScalar]( [page:Float s] ) [page:Matrix4 this]</h3>
  95. <div>
  96. Multiplies every component of the matrix by a scalar value *s*.
  97. </div>
  98. <h3>[method:Float determinant]() [page:Matrix4 this]</h3>
  99. <div>
  100. Computes and returns the determinant of this matrix.<br />
  101. Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm]
  102. </div>
  103. <h3>[method:Matrix4 transpose]() [page:Matrix4 this]</h3>
  104. <div>
  105. Transposes this matrix.
  106. </div>
  107. <h3>[method:Matrix4 setPosition]( [page:Vector3 v] ) [page:Matrix4 this]</h3>
  108. <div>
  109. Sets the position component for this matrix from vector *v*.
  110. </div>
  111. <h3>[method:Matrix4 getInverse]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
  112. <div>
  113. Sets this matrix to the inverse of matrix *m*.<br />
  114. Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm].
  115. </div>
  116. <h3>[method:Matrix4 makeRotationFromEuler]( [page:Euler euler] ) [page:Matrix4 this]</h3>
  117. <div>
  118. euler — Rotation vector followed by order of rotations, e.g., "XYZ".
  119. </div>
  120. <div>
  121. Sets the rotation submatrix of this matrix to the rotation specified by Euler angles, the rest of the matrix is identity.<br />
  122. Default order is *"XYZ"*.
  123. </div>
  124. <h3>[method:Matrix4 makeRotationFromQuaternion]( [page:Quaternion q] ) [page:Matrix4 this]</h3>
  125. <div>
  126. Sets the rotation submatrix of this matrix to the rotation specified by *q*. The rest of the matrix is identity.
  127. </div>
  128. <h3>[method:Matrix4 scale]( [page:Vector3 v] ) [page:Matrix4 this]</h3>
  129. <div>
  130. Multiplies the columns of this matrix by vector *v*.
  131. </div>
  132. <h3>[method:Matrix4 compose]( [page:Vector3 translation], [page:Quaternion quaternion], [page:Vector3 scale] ) [page:Matrix4 this]</h3>
  133. <div>
  134. Sets this matrix to the transformation composed of *translation*, *quaternion* and *scale*.
  135. </div>
  136. <h3>[method:null decompose]( [page:Vector3 translation], [page:Quaternion quaternion], [page:Vector3 scale] ) [page:Matrix4 this]</h3>
  137. <div>
  138. Decomposes this matrix into the *translation*, *quaternion* and *scale* components.
  139. </div>
  140. <h3>[method:Matrix4 makeTranslation]( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4 this]</h3>
  141. <div>
  142. Sets this matrix as translation transform.
  143. </div>
  144. <h3>[method:Matrix4 makeRotationX]( [page:Float theta] ) [page:Matrix4 this]</h3>
  145. <div>
  146. theta — Rotation angle in radians.
  147. </div>
  148. <div>
  149. Sets this matrix as rotation transform around x axis by *theta* radians.
  150. </div>
  151. <h3>[method:Matrix4 makeRotationY]( [page:Float theta] ) [page:Matrix4 this]</h3>
  152. <div>
  153. theta — Rotation angle in radians.
  154. </div>
  155. <div>
  156. Sets this matrix as rotation transform around y axis by *theta* radians.
  157. </div>
  158. <h3>[method:Matrix4 makeRotationZ]( [page:Float theta] ) [page:Matrix4 this]</h3>
  159. <div>
  160. theta — Rotation angle in radians.
  161. </div>
  162. <div>
  163. Sets this matrix as rotation transform around z axis by *theta* radians.
  164. </div>
  165. <h3>[method:Matrix4 makeRotationAxis]( [page:Vector3 axis], [page:Float theta] ) [page:Matrix4 this]</h3>
  166. <div>
  167. axis — Rotation axis, should be normalized.
  168. theta — Rotation angle in radians.
  169. </div>
  170. <div>
  171. Sets this matrix as rotation transform around *axis* by *angle* radians.<br />
  172. Based on [link:http://www.gamedev.net/reference/articles/article1199.asp].
  173. </div>
  174. <h3>[method:Matrix4 makeScale]( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4 this]</h3>
  175. <div>
  176. Sets this matrix as scale transform.
  177. </div>
  178. <h3>[method:Matrix4 makeFrustum]( [page:Float left], [page:Float right], [page:Float bottom], [page:Float top], [page:Float near], [page:Float far] ) [page:Matrix4 this]</h3>
  179. <div>
  180. Creates a [page:Frustum frustum] matrix.
  181. </div>
  182. <h3>[method:Matrix4 makePerspective]( [page:Float fov], [page:Float aspect], [page:Float near], [page:Float far] ) [page:Matrix4 this]</h3>
  183. <div>
  184. Creates a perspective projection matrix.
  185. </div>
  186. <h3>[method:Matrix4 makeOrthographic]( [page:Float left], [page:Float right], [page:Float top], [page:Float bottom], [page:Float near], [page:Float far] ) [page:Matrix4 this]</h3>
  187. <div>
  188. Creates an orthographic projection matrix.
  189. </div>
  190. <h3>[method:Array applyToVector3Array]( [page:Array a] ) [page:Matrix4 this]</h3>
  191. <div>
  192. array -- An array in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...]
  193. </div>
  194. <div>
  195. Multiplies (applies) this matrix to every vector3 in the array.
  196. </div>
  197. <h3>[method:Float getMaxScaleOnAxis]() [page:Matrix4 this]</h3>
  198. <div>
  199. Gets the maximum scale value of the 3 axes.
  200. </div>
  201. <h3>[method:Matrix4 clone]() [page:Matrix4 this]</h3>
  202. <div>
  203. Creates a copy of this matrix.
  204. </div>
  205. <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] ) [page:Matrix4 this]</h3>
  206. <div>
  207. array -- [page:Array] optional array to store the vector <br />
  208. offset -- [page:Integer] optional offset into the array
  209. </div>
  210. <div>
  211. Writes the elements of this matrix to an array in column-major format.
  212. </div>
  213. <h2>Source</h2>
  214. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  215. </body>
  216. </html>