Matrix2.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Matrix2 - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">Matrix2</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Represents a 2x2 matrix.</p>
  16. <p>A Note on Row-Major and Column-Major Ordering:</p>
  17. <p>The constructor and <a href="Matrix2.html#set">Matrix2#set</a> method take arguments in
  18. <a href="https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order" target="_blank" rel="noopener">row-major</a>
  19. order, while internally they are stored in the <a href="Matrix2.html#elements">Matrix2#elements</a> array in column-major order.
  20. This means that calling:</p>
  21. <pre><code class="language-js">const m = new THREE.Matrix2();
  22. m.set( 11, 12,
  23. 21, 22 );
  24. </code></pre>
  25. <p>will result in the elements array containing:</p>
  26. <pre><code class="language-js">m.elements = [ 11, 21,
  27. 12, 22 ];
  28. </code></pre>
  29. <p>and internally all calculations are performed using column-major ordering.
  30. However, as the actual ordering makes no difference mathematically and
  31. most people are used to thinking about matrices in row-major order, the
  32. three.js documentation shows matrices in row-major order. Just bear in
  33. mind that if you are reading the source code, you'll have to take the
  34. transpose of any matrices outlined here to make sense of the calculations.</p></div>
  35. </header>
  36. <article>
  37. <div class="container-overview">
  38. <h2>Constructor</h2>
  39. <h3 class="name name-method" id="Matrix2" translate="no">new <a href="#Matrix2">Matrix2</a><span class="signature">( n11 : <span class="param-type">number</span>, n12 : <span class="param-type">number</span>, n21 : <span class="param-type">number</span>, n22 : <span class="param-type">number</span> )</span> </h3>
  40. <div class="method">
  41. <div class="description">
  42. <p>Constructs a new 2x2 matrix. The arguments are supposed to be
  43. in row-major order. If no arguments are provided, the constructor
  44. initializes the matrix as an identity matrix.</p>
  45. </div>
  46. <table class="params">
  47. <tbody>
  48. <tr>
  49. <td class="name">
  50. <strong translate="no">n11</strong>
  51. </td>
  52. <td class="description last">
  53. <p>1-1 matrix element.</p>
  54. </td>
  55. </tr>
  56. <tr>
  57. <td class="name">
  58. <strong translate="no">n12</strong>
  59. </td>
  60. <td class="description last">
  61. <p>1-2 matrix element.</p>
  62. </td>
  63. </tr>
  64. <tr>
  65. <td class="name">
  66. <strong translate="no">n21</strong>
  67. </td>
  68. <td class="description last">
  69. <p>2-1 matrix element.</p>
  70. </td>
  71. </tr>
  72. <tr>
  73. <td class="name">
  74. <strong translate="no">n22</strong>
  75. </td>
  76. <td class="description last">
  77. <p>2-2 matrix element.</p>
  78. </td>
  79. </tr>
  80. </tbody>
  81. </table>
  82. </div>
  83. </div>
  84. <h2 class="subsection-title">Classes</h2>
  85. <dl>
  86. <dt><a href="Matrix2.html">Matrix2</a></dt>
  87. <dd></dd>
  88. </dl>
  89. <h2 class="subsection-title">Properties</h2>
  90. <div class="member">
  91. <h3 class="name" id="elements" translate="no">.<a href="#elements">elements</a><span class="type-signature"> : Array.&lt;number></span> </h3>
  92. <div class="description">
  93. <p>A column-major list of matrix values.</p>
  94. </div>
  95. </div>
  96. <h2 class="subsection-title">Methods</h2>
  97. <h3 class="name name-method" id="fromArray" translate="no">.<a href="#fromArray">fromArray</a><span class="signature">( array : <span class="param-type">Array.&lt;number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix2.html">Matrix2</a></span> </h3>
  98. <div class="method">
  99. <div class="description">
  100. <p>Sets the elements of the matrix from the given array.</p>
  101. </div>
  102. <table class="params">
  103. <tbody>
  104. <tr>
  105. <td class="name">
  106. <strong translate="no">array</strong>
  107. </td>
  108. <td class="description last">
  109. <p>The matrix elements in column-major order.</p>
  110. </td>
  111. </tr>
  112. <tr>
  113. <td class="name">
  114. <strong translate="no">offset</strong>
  115. </td>
  116. <td class="description last">
  117. <p>Index of the first element in the array.</p>
  118. <p>Default is <code>0</code>.</p>
  119. </td>
  120. </tr>
  121. </tbody>
  122. </table>
  123. <dl class="details">
  124. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  125. </dl>
  126. </div>
  127. <h3 class="name name-method" id="identity" translate="no">.<a href="#identity">identity</a><span class="signature">()</span><span class="type-signature"> : <a href="Matrix2.html">Matrix2</a></span> </h3>
  128. <div class="method">
  129. <div class="description">
  130. <p>Sets this matrix to the 2x2 identity matrix.</p>
  131. </div>
  132. <dl class="details">
  133. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  134. </dl>
  135. </div>
  136. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( n11 : <span class="param-type">number</span>, n12 : <span class="param-type">number</span>, n21 : <span class="param-type">number</span>, n22 : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix2.html">Matrix2</a></span> </h3>
  137. <div class="method">
  138. <div class="description">
  139. <p>Sets the elements of the matrix.The arguments are supposed to be
  140. in row-major order.</p>
  141. </div>
  142. <table class="params">
  143. <tbody>
  144. <tr>
  145. <td class="name">
  146. <strong translate="no">n11</strong>
  147. </td>
  148. <td class="description last">
  149. <p>1-1 matrix element.</p>
  150. </td>
  151. </tr>
  152. <tr>
  153. <td class="name">
  154. <strong translate="no">n12</strong>
  155. </td>
  156. <td class="description last">
  157. <p>1-2 matrix element.</p>
  158. </td>
  159. </tr>
  160. <tr>
  161. <td class="name">
  162. <strong translate="no">n21</strong>
  163. </td>
  164. <td class="description last">
  165. <p>2-1 matrix element.</p>
  166. </td>
  167. </tr>
  168. <tr>
  169. <td class="name">
  170. <strong translate="no">n22</strong>
  171. </td>
  172. <td class="description last">
  173. <p>2-2 matrix element.</p>
  174. </td>
  175. </tr>
  176. </tbody>
  177. </table>
  178. <dl class="details">
  179. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  180. </dl>
  181. </div>
  182. <h2 class="subsection-title">Source</h2>
  183. <p>
  184. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Matrix2.js" translate="no" target="_blank" rel="noopener">src/math/Matrix2.js</a>
  185. </p>
  186. </article>
  187. </section>
  188. <script src="../scripts/linenumber.js"></script>
  189. <script src="../scripts/page.js"></script>
  190. </body>
  191. </html>
粤ICP备19079148号