Matrix3.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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">
  13. A class representing a 3x3 [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].
  14. </div>
  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. <div>
  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 transpose of any matrices outlined here to make sense of the calculations.
  39. </div>
  40. <h2>Constructor</h2>
  41. <h3>[name]()</h3>
  42. <div>
  43. Creates and initializes the [name] to the 3x3
  44. [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
  45. </div>
  46. <h2>Properties</h2>
  47. <h3>[property:Float32Array elements]</h3>
  48. <div>
  49. A [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]
  50. list of matrix values.
  51. </div>
  52. <h3>[property:Boolean isMatrix3]</h3>
  53. <div>
  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. </div>
  57. <h2>Methods</h2>
  58. <h3>[method:Array applyToBufferAttribute]( [page:BufferAttribute attribute] )</h3>
  59. <div>
  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. </div>
  63. <h3>[method:Array applyToVector3Array]( [page:Array array], [page:Number offset], [page:Number length] )</h3>
  64. <div>
  65. [page:Array array] - An array of floats in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...],
  66. that represent 3D vectors.<br />
  67. [page:Number offset] - (optional) index in the array of the first vector's x component. Default is 0.<br />
  68. [page:Number length] - (optional) index in the array of the last vector's z component.
  69. Default is the last element in the array.<br /><br />
  70. Multiplies (applies) this matrix to every 3D vector in the [page:Array array].
  71. </div>
  72. <h3>[method:Matrix3 clone]()</h3>
  73. <div>Creates a new Matrix3 and with identical elements to this one.</div>
  74. <h3>[method:Matrix3 copy]( [page:Matrix3 m] )</h3>
  75. <div>Copies the elements of matrix [page:Matrix3 m] into this matrix.</div>
  76. <h3>[method:Float determinant]()</h3>
  77. <div>
  78. Computes and returns the
  79. [link:https://en.wikipedia.org/wiki/Determinant determinant] of this matrix.
  80. </div>
  81. <h3>[method:Matrix3 fromArray]( [page:Array array], [page:Integer offset] )</h3>
  82. <div>
  83. [page:Array array] - the array to read the elements from.<br />
  84. [page:Integer offset] - (optional) index of first element in the array. Default is 0.<br /><br />
  85. Sets the elements of this matrix based on an array in
  86. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  87. </div>
  88. <h3>[method:Matrix3 getInverse]( [page:Matrix3 m], [page:Boolean throwOnDegenerate] )</h3>
  89. <div>
  90. [page:Matrix3 m] - the matrix to take the inverse of.<br />
  91. [page:Boolean throwOnDegenerate] - (optional) If true, throw an error if the matrix is degenerate (not invertible).<br /><br />
  92. Set this matrix to the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] of the passed matrix [page:Matrix3 m],
  93. using the [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method].
  94. If [page:Boolean throwOnDegenerate] is not set and the matrix is not invertible, set this to the 3x3 identity matrix.
  95. </div>
  96. <h3>[method:Matrix3 getNormalMatrix]( [page:Matrix4 m] )</h3>
  97. <div>
  98. [page:Matrix4 m] - [page:Matrix4]<br /><br />
  99. Sets this matrix as the upper left 3x3 of the [link:https://en.wikipedia.org/wiki/Normal_matrix normal matrix]
  100. 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]
  101. of the matrix [page:Matrix4 m].
  102. </div>
  103. <h3>[method:Matrix3 identity]()</h3>
  104. <div>
  105. Resets this matrix to the 3x3 identity matrix:
  106. <code>
  107. 1, 0, 0
  108. 0, 1, 0
  109. 0, 0, 1
  110. </code>
  111. </div>
  112. <h3>[method:Matrix3 multiplyScalar]( [page:Float s] )</h3>
  113. <div>Multiplies every component of the matrix by the scalar value *s*.</div>
  114. <h3>
  115. [method:Matrix3 set](
  116. [page:Float n11], [page:Float n12], [page:Float n13],
  117. [page:Float n21], [page:Float n22], [page:Float n23],
  118. [page:Float n31], [page:Float n32], [page:Float n33] )
  119. </h3>
  120. <div>
  121. [page:Float n11] - value to put in row 1, col 1.<br />
  122. [page:Float n12] - value to put in row 1, col 2.<br />
  123. ...<br />
  124. ...<br />
  125. [page:Float n32] - value to put in row 3, col 2.<br />
  126. [page:Float n33] - value to put in row 3, col 3.<br /><br />
  127. Sets the 3x3 matrix values to the given
  128. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major]
  129. sequence of values.
  130. </div>
  131. <h3>[method:Matrix3 setFromMatrix4]( [page:Matrix4 m] )</h3>
  132. <div>Set this matrx to the upper 3x3 matrix of the Matrix4 [page:Matrix4 m].</div>
  133. <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] )</h3>
  134. <div>
  135. [page:Array array] - (optional) array to store the resulting vector in. If not given a new array will be created.<br />
  136. [page:Integer offset] - (optional) offset in the array at which to put the result.<br /><br />
  137. Writes the elements of this matrix to an array in
  138. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  139. </div>
  140. <h3>[method:Matrix3 transpose]()</h3>
  141. <div>[link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix in place.</div>
  142. <h3>[method:Matrix3 transposeIntoArray]( [page:Array array] )</h3>
  143. <div>
  144. [page:Array array] - array to store the resulting vector in.<br /><br />
  145. [link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix into the supplied array,
  146. and returns itself unchanged.
  147. </div>
  148. <h2>Source</h2>
  149. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  150. </body>
  151. </html>