Matrix3.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 [link:https://en.wikipedia.org/wiki/Transpose 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:Matrix3 clone]()</h3>
  64. <div>Creates a new Matrix3 and with identical elements to this one.</div>
  65. <h3>[method:Matrix3 copy]( [page:Matrix3 m] )</h3>
  66. <div>Copies the elements of matrix [page:Matrix3 m] into this matrix.</div>
  67. <h3>[method:Float determinant]()</h3>
  68. <div>
  69. Computes and returns the
  70. [link:https://en.wikipedia.org/wiki/Determinant determinant] of this matrix.
  71. </div>
  72. <h3>[method:Matrix3 fromArray]( [page:Array array], [page:Integer offset] )</h3>
  73. <div>
  74. [page:Array array] - the array to read the elements from.<br />
  75. [page:Integer offset] - (optional) index of first element in the array. Default is 0.<br /><br />
  76. Sets the elements of this matrix based on an array in
  77. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  78. </div>
  79. <h3>[method:Matrix3 getInverse]( [page:Matrix3 m], [page:Boolean throwOnDegenerate] )</h3>
  80. <div>
  81. [page:Matrix3 m] - the matrix to take the inverse of.<br />
  82. [page:Boolean throwOnDegenerate] - (optional) If true, throw an error if the matrix is degenerate (not invertible).<br /><br />
  83. Set this matrix to the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] of the passed matrix [page:Matrix3 m],
  84. using the [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method].
  85. If [page:Boolean throwOnDegenerate] is not set and the matrix is not invertible, set this to the 3x3 identity matrix.
  86. </div>
  87. <h3>[method:Matrix3 getNormalMatrix]( [page:Matrix4 m] )</h3>
  88. <div>
  89. [page:Matrix4 m] - [page:Matrix4]<br /><br />
  90. Sets this matrix as the upper left 3x3 of the [link:https://en.wikipedia.org/wiki/Normal_matrix normal matrix]
  91. 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]
  92. of the matrix [page:Matrix4 m].
  93. </div>
  94. <h3>[method:Matrix3 identity]()</h3>
  95. <div>
  96. Resets this matrix to the 3x3 identity matrix:
  97. <code>
  98. 1, 0, 0
  99. 0, 1, 0
  100. 0, 0, 1
  101. </code>
  102. </div>
  103. <h3>[method:Matrix3 multiplyScalar]( [page:Float s] )</h3>
  104. <div>Multiplies every component of the matrix by the scalar value *s*.</div>
  105. <h3>
  106. [method:Matrix3 set](
  107. [page:Float n11], [page:Float n12], [page:Float n13],
  108. [page:Float n21], [page:Float n22], [page:Float n23],
  109. [page:Float n31], [page:Float n32], [page:Float n33] )
  110. </h3>
  111. <div>
  112. [page:Float n11] - value to put in row 1, col 1.<br />
  113. [page:Float n12] - value to put in row 1, col 2.<br />
  114. ...<br />
  115. ...<br />
  116. [page:Float n32] - value to put in row 3, col 2.<br />
  117. [page:Float n33] - value to put in row 3, col 3.<br /><br />
  118. Sets the 3x3 matrix values to the given
  119. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major]
  120. sequence of values.
  121. </div>
  122. <h3>[method:Matrix3 setFromMatrix4]( [page:Matrix4 m] )</h3>
  123. <div>Set this matrx to the upper 3x3 matrix of the Matrix4 [page:Matrix4 m].</div>
  124. <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] )</h3>
  125. <div>
  126. [page:Array array] - (optional) array to store the resulting vector in. If not given a new array will be created.<br />
  127. [page:Integer offset] - (optional) offset in the array at which to put the result.<br /><br />
  128. Writes the elements of this matrix to an array in
  129. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  130. </div>
  131. <h3>[method:Matrix3 transpose]()</h3>
  132. <div>[link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix in place.</div>
  133. <h3>[method:Matrix3 transposeIntoArray]( [page:Array array] )</h3>
  134. <div>
  135. [page:Array array] - array to store the resulting vector in.<br /><br />
  136. [link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix into the supplied array,
  137. and returns itself unchanged.
  138. </div>
  139. <h2>Source</h2>
  140. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  141. </body>
  142. </html>