Matrix3.html 6.8 KB

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