Matrix3.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <p class="desc">
  12. A class representing a 3x3 [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].
  13. </p>
  14. <h2>Code Example</h2>
  15. <code>
  16. const m = new Matrix3();
  17. </code>
  18. <h2>A Note on Row-Major and Column-Major Ordering</h2>
  19. <p>
  20. The [page:set]() method takes arguments in [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major]
  21. order, while internally they are stored in the [page:.elements elements] array in column-major order.<br /><br />
  22. This means that calling
  23. <code>
  24. m.set( 11, 12, 13,
  25. 21, 22, 23,
  26. 31, 32, 33 );
  27. </code>
  28. will result in the [page:.elements elements] array containing:
  29. <code>
  30. m.elements = [ 11, 21, 31,
  31. 12, 22, 32,
  32. 13, 23, 33 ];
  33. </code>
  34. and internally all calculations are performed using column-major ordering. However, as the actual ordering
  35. makes no difference mathematically and most people are used to thinking about matrices in row-major order,
  36. the three.js documentation shows matrices in row-major order. Just bear in mind that if you are reading the source
  37. code, you'll have to take the [link:https://en.wikipedia.org/wiki/Transpose transpose] of any matrices outlined here to make sense of the calculations.
  38. </p>
  39. <h2>Constructor</h2>
  40. <h3>[name]()</h3>
  41. <p>
  42. Creates and initializes the [name] to the 3x3
  43. [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
  44. </p>
  45. <h2>Properties</h2>
  46. <h3>[property:Array elements]</h3>
  47. <p>
  48. A [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]
  49. list of matrix values.
  50. </p>
  51. <h2>Methods</h2>
  52. <h3>[method:Matrix3 clone]()</h3>
  53. <p>Creates a new Matrix3 and with identical elements to this one.</p>
  54. <h3>[method:this copy]( [param:Matrix3 m] )</h3>
  55. <p>Copies the elements of matrix [page:Matrix3 m] into this matrix.</p>
  56. <h3>[method:Float determinant]()</h3>
  57. <p>
  58. Computes and returns the
  59. [link:https://en.wikipedia.org/wiki/Determinant determinant] of this matrix.
  60. </p>
  61. <h3>[method:Boolean equals]( [param:Matrix3 m] )</h3>
  62. <p>Return true if this matrix and [page:Matrix3 m] are equal.</p>
  63. <h3>[method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )</h3>
  64. <p>
  65. Extracts the [link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis] of this
  66. matrix into the three axis vectors provided. If this matrix is:
  67. <code>
  68. a, b, c,
  69. d, e, f,
  70. g, h, i
  71. </code>
  72. then the [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] will be set to:
  73. <code>
  74. xAxis = (a, d, g)
  75. yAxis = (b, e, h)
  76. zAxis = (c, f, i)
  77. </code>
  78. </p>
  79. <h3>[method:this fromArray]( [param:Array array], [param:Integer offset] )</h3>
  80. <p>
  81. [page:Array array] - the array to read the elements from.<br />
  82. [page:Integer offset] - (optional) index of first element in the array. Default is 0.<br /><br />
  83. Sets the elements of this matrix based on an array in
  84. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  85. </p>
  86. <h3>[method:this invert]()</h3>
  87. <p>
  88. Inverts this matrix, using the [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method].
  89. You can not invert with a determinant of zero. If you attempt this, the method produces a zero matrix instead.
  90. </p>
  91. <h3>[method:this getNormalMatrix]( [param:Matrix4 m] )</h3>
  92. <p>
  93. [page:Matrix4 m] - [page:Matrix4]<br /><br />
  94. Sets this matrix as the upper left 3x3 of the [link:https://en.wikipedia.org/wiki/Normal_matrix normal matrix]
  95. of the passed [page:Matrix4 matrix4]. The normal matrix is the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] [link:https://en.wikipedia.org/wiki/Transpose transpose]
  96. of the matrix [page:Matrix4 m].
  97. </p>
  98. <h3>[method:this identity]()</h3>
  99. <p>
  100. Resets this matrix to the 3x3 identity matrix:
  101. <code>
  102. 1, 0, 0
  103. 0, 1, 0
  104. 0, 0, 1
  105. </code>
  106. </p>
  107. <h3>[method:this multiply]( [param:Matrix3 m] )</h3>
  108. <p>Post-multiplies this matrix by [page:Matrix3 m].</p>
  109. <h3>[method:this multiplyMatrices]( [param:Matrix3 a], [param:Matrix3 b] )</h3>
  110. <p>Sets this matrix to [page:Matrix3 a] x [page:Matrix3 b].</p>
  111. <h3>[method:this multiplyScalar]( [param:Float s] )</h3>
  112. <p>Multiplies every component of the matrix by the scalar value *s*.</p>
  113. <h3>[method:this set]( [param:Float n11], [param:Float n12], [param:Float n13], [param:Float n21], [param:Float n22], [param:Float n23], [param:Float n31], [param:Float n32], [param:Float n33] )</h3>
  114. <p>
  115. [page:Float n11] - value to put in row 1, col 1.<br />
  116. [page:Float n12] - value to put in row 1, col 2.<br />
  117. ...<br />
  118. ...<br />
  119. [page:Float n32] - value to put in row 3, col 2.<br />
  120. [page:Float n33] - value to put in row 3, col 3.<br /><br />
  121. Sets the 3x3 matrix values to the given
  122. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major]
  123. sequence of values.
  124. </p>
  125. <h3>[method:this premultiply]( [param:Matrix3 m] )</h3>
  126. <p>Pre-multiplies this matrix by [page:Matrix3 m].</p>
  127. <h3>[method:this setFromMatrix4]( [param:Matrix4 m] )</h3>
  128. <p>Set this matrix to the upper 3x3 matrix of the Matrix4 [page:Matrix4 m].</p>
  129. <h3>[method:this setUvTransform]( [param:Float tx], [param:Float ty], [param:Float sx], [param:Float sy], [param:Float rotation], [param:Float cx], [param:Float cy] )</h3>
  130. <p>
  131. [page:Float tx] - offset x<br />
  132. [page:Float ty] - offset y<br />
  133. [page:Float sx] - repeat x<br />
  134. [page:Float sy] - repeat y<br />
  135. [page:Float rotation] - rotation (in radians)<br />
  136. [page:Float cx] - center x of rotation<br />
  137. [page:Float cy] - center y of rotation<br /><br />
  138. Sets the UV transform matrix from offset, repeat, rotation, and center.
  139. </p>
  140. <h3>[method:Array toArray]( [param:Array array], [param:Integer offset] )</h3>
  141. <p>
  142. [page:Array array] - (optional) array to store the resulting vector in. If not given a new array will be created.<br />
  143. [page:Integer offset] - (optional) offset in the array at which to put the result.<br /><br />
  144. Writes the elements of this matrix to an array in
  145. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  146. </p>
  147. <h3>[method:this transpose]()</h3>
  148. <p>[link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix in place.</p>
  149. <h3>[method:this transposeIntoArray]( [param:Array array] )</h3>
  150. <p>
  151. [page:Array array] - array to store the resulting vector in.<br /><br />
  152. [link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix into the supplied array,
  153. and returns itself unchanged.
  154. </p>
  155. <h2>Source</h2>
  156. <p>
  157. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  158. </p>
  159. </body>
  160. </html>