2
0

Matrix3.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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:Float32Array 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. <h3>[property:Boolean isMatrix3]</h3>
  53. <p>
  54. Used to check whether this or derived classes are Matrix3s. Default is *true*.<br /><br />
  55. You should not change this, as it used internally for optimisation.
  56. </p>
  57. <h2>Methods</h2>
  58. <h3>[method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )</h3>
  59. <p>
  60. [page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br /><br />
  61. Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute].
  62. </p>
  63. <h3>[method:Matrix3 clone]()</h3>
  64. <p>Creates a new Matrix3 and with identical elements to this one.</p>
  65. <h3>[method:this copy]( [param:Matrix3 m] )</h3>
  66. <p>Copies the elements of matrix [page:Matrix3 m] into this matrix.</p>
  67. <h3>[method:Float determinant]()</h3>
  68. <p>
  69. Computes and returns the
  70. [link:https://en.wikipedia.org/wiki/Determinant determinant] of this matrix.
  71. </p>
  72. <h3>[method:Boolean equals]( [param:Matrix3 m] )</h3>
  73. <p>Return true if this matrix and [page:Matrix3 m] are equal.</p>
  74. <h3>[method:this fromArray]( [param:Array array], [param:Integer offset] )</h3>
  75. <p>
  76. [page:Array array] - the array to read the elements from.<br />
  77. [page:Integer offset] - (optional) index of first element in the array. Default is 0.<br /><br />
  78. Sets the elements of this matrix based on an array in
  79. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  80. </p>
  81. <h3>[method:this getInverse]( [param:Matrix3 m], [param:Boolean throwOnDegenerate] )</h3>
  82. <p>
  83. [page:Matrix3 m] - the matrix to take the inverse of.<br />
  84. [page:Boolean throwOnDegenerate] - (optional) If true, throw an error if the matrix is degenerate (not invertible).<br /><br />
  85. Set this matrix to the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] of the passed matrix [page:Matrix3 m],
  86. using the [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method].
  87. If [page:Boolean throwOnDegenerate] is not set and the matrix is not invertible, set this to the 3x3 identity matrix.
  88. </p>
  89. <h3>[method:this getNormalMatrix]( [param:Matrix4 m] )</h3>
  90. <p>
  91. [page:Matrix4 m] - [page:Matrix4]<br /><br />
  92. Sets this matrix as the upper left 3x3 of the [link:https://en.wikipedia.org/wiki/Normal_matrix normal matrix]
  93. 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]
  94. of the matrix [page:Matrix4 m].
  95. </p>
  96. <h3>[method:this identity]()</h3>
  97. <p>
  98. Resets this matrix to the 3x3 identity matrix:
  99. <code>
  100. 1, 0, 0
  101. 0, 1, 0
  102. 0, 0, 1
  103. </code>
  104. </p>
  105. <h3>[method:this multiply]( [param:Matrix3 m] )</h3>
  106. <p>Post-multiplies this matrix by [page:Matrix3 m].</p>
  107. <h3>[method:this multiplyMatrices]( [param:Matrix3 a], [param:Matrix3 b] )</h3>
  108. <p>Sets this matrix to [page:Matrix3 a] x [page:Matrix3 b].</p>
  109. <h3>[method:this multiplyScalar]( [param:Float s] )</h3>
  110. <p>Multiplies every component of the matrix by the scalar value *s*.</p>
  111. <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>
  112. <p>
  113. [page:Float n11] - value to put in row 1, col 1.<br />
  114. [page:Float n12] - value to put in row 1, col 2.<br />
  115. ...<br />
  116. ...<br />
  117. [page:Float n32] - value to put in row 3, col 2.<br />
  118. [page:Float n33] - value to put in row 3, col 3.<br /><br />
  119. Sets the 3x3 matrix values to the given
  120. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major]
  121. sequence of values.
  122. </p>
  123. <h3>[method:this premultiply]( [param:Matrix3 m] )</h3>
  124. <p>Pre-multiplies this matrix by [page:Matrix3 m].</p>
  125. <h3>[method:this setFromMatrix4]( [param:Matrix4 m] )</h3>
  126. <p>Set this matrx to the upper 3x3 matrix of the Matrix4 [page:Matrix4 m].</p>
  127. <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>
  128. <p>
  129. [page:Float tx] - offset x<br />
  130. [page:Float ty] - offset y<br />
  131. [page:Float sx] - repeat x<br />
  132. [page:Float sy] - repeat y<br />
  133. [page:Float rotation] - rotation (in radians)<br />
  134. [page:Float cx] - center x of rotation<br />
  135. [page:Float cy] - center y of rotation<br /><br />
  136. Sets the UV transform matrix from offset, repeat, rotation, and center.
  137. </p>
  138. <h3>[method:Array toArray]( [param:Array array], [param:Integer offset] )</h3>
  139. <p>
  140. [page:Array array] - (optional) array to store the resulting vector in. If not given a new array will be created.<br />
  141. [page:Integer offset] - (optional) offset in the array at which to put the result.<br /><br />
  142. Writes the elements of this matrix to an array in
  143. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  144. </p>
  145. <h3>[method:this transpose]()</h3>
  146. <p>[link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix in place.</p>
  147. <h3>[method:this transposeIntoArray]( [param:Array array] )</h3>
  148. <p>
  149. [page:Array array] - array to store the resulting vector in.<br /><br />
  150. [link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix into the supplied array,
  151. and returns itself unchanged.
  152. </p>
  153. <h2>Source</h2>
  154. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  155. </body>
  156. </html>