Matrix2.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. <p>will result in the elements array containing:</p>
  22. <pre><code class="language-js">m.elements = [ 11, 21,
  23. 12, 22 ];
  24. </code></pre>
  25. <p>and internally all calculations are performed using column-major ordering.
  26. However, as the actual ordering makes no difference mathematically and
  27. most people are used to thinking about matrices in row-major order, the
  28. three.js documentation shows matrices in row-major order. Just bear in
  29. mind that if you are reading the source code, you'll have to take the
  30. transpose of any matrices outlined here to make sense of the calculations.</p></div>
  31. <h2>Code Example</h2>
  32. <div translate="no"><pre><code class="language-js">const m = new THREE.Matrix2();
  33. m.set( 11, 12,
  34. 21, 22 );
  35. </code></pre></div>
  36. </header>
  37. <article>
  38. <div class="container-overview">
  39. <h2>Constructor</h2>
  40. <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>
  41. <div class="method">
  42. <div class="description">
  43. <p>Constructs a new 2x2 matrix. The arguments are supposed to be
  44. in row-major order. If no arguments are provided, the constructor
  45. initializes the matrix as an identity matrix.</p>
  46. </div>
  47. <table class="params">
  48. <tbody>
  49. <tr>
  50. <td class="name">
  51. <strong>n11</strong>
  52. </td>
  53. <td class="description last">
  54. <p>1-1 matrix element.</p>
  55. </td>
  56. </tr>
  57. <tr>
  58. <td class="name">
  59. <strong>n12</strong>
  60. </td>
  61. <td class="description last">
  62. <p>1-2 matrix element.</p>
  63. </td>
  64. </tr>
  65. <tr>
  66. <td class="name">
  67. <strong>n21</strong>
  68. </td>
  69. <td class="description last">
  70. <p>2-1 matrix element.</p>
  71. </td>
  72. </tr>
  73. <tr>
  74. <td class="name">
  75. <strong>n22</strong>
  76. </td>
  77. <td class="description last">
  78. <p>2-2 matrix element.</p>
  79. </td>
  80. </tr>
  81. </tbody>
  82. </table>
  83. </div>
  84. </div>
  85. <h2 class="subsection-title">Classes</h2>
  86. <dl>
  87. <dt><a href="Matrix2.html">Matrix2</a></dt>
  88. <dd></dd>
  89. </dl>
  90. <h2 class="subsection-title">Properties</h2>
  91. <div class="member">
  92. <h3 class="name" id="elements" translate="no">.<a href="#elements">elements</a><span class="type-signature"> : Array.&lt;number></span> </h3>
  93. <div class="description">
  94. <p>A column-major list of matrix values.</p>
  95. </div>
  96. </div>
  97. <div class="member">
  98. <h3 class="name" id="isMatrix2" translate="no">.<a href="#isMatrix2">isMatrix2</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  99. <div class="description">
  100. <p>This flag can be used for type testing.</p>
  101. <p>Default is <code>true</code>.</p>
  102. </div>
  103. </div>
  104. <h2 class="subsection-title">Methods</h2>
  105. <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>
  106. <div class="method">
  107. <div class="description">
  108. <p>Sets the elements of the matrix from the given array.</p>
  109. </div>
  110. <table class="params">
  111. <tbody>
  112. <tr>
  113. <td class="name">
  114. <strong>array</strong>
  115. </td>
  116. <td class="description last">
  117. <p>The matrix elements in column-major order.</p>
  118. </td>
  119. </tr>
  120. <tr>
  121. <td class="name">
  122. <strong>offset</strong>
  123. </td>
  124. <td class="description last">
  125. <p>Index of the first element in the array.</p>
  126. <p>Default is <code>0</code>.</p>
  127. </td>
  128. </tr>
  129. </tbody>
  130. </table>
  131. <dl class="details">
  132. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  133. </dl>
  134. </div>
  135. <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>
  136. <div class="method">
  137. <div class="description">
  138. <p>Sets this matrix to the 2x2 identity matrix.</p>
  139. </div>
  140. <dl class="details">
  141. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  142. </dl>
  143. </div>
  144. <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>
  145. <div class="method">
  146. <div class="description">
  147. <p>Sets the elements of the matrix.The arguments are supposed to be
  148. in row-major order.</p>
  149. </div>
  150. <table class="params">
  151. <tbody>
  152. <tr>
  153. <td class="name">
  154. <strong>n11</strong>
  155. </td>
  156. <td class="description last">
  157. <p>1-1 matrix element.</p>
  158. </td>
  159. </tr>
  160. <tr>
  161. <td class="name">
  162. <strong>n12</strong>
  163. </td>
  164. <td class="description last">
  165. <p>1-2 matrix element.</p>
  166. </td>
  167. </tr>
  168. <tr>
  169. <td class="name">
  170. <strong>n21</strong>
  171. </td>
  172. <td class="description last">
  173. <p>2-1 matrix element.</p>
  174. </td>
  175. </tr>
  176. <tr>
  177. <td class="name">
  178. <strong>n22</strong>
  179. </td>
  180. <td class="description last">
  181. <p>2-2 matrix element.</p>
  182. </td>
  183. </tr>
  184. </tbody>
  185. </table>
  186. <dl class="details">
  187. <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
  188. </dl>
  189. </div>
  190. <h2 class="subsection-title">Source</h2>
  191. <p>
  192. <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>
  193. </p>
  194. </article>
  195. </section>
  196. <script src="../scripts/linenumber.js"></script>
  197. <script src="../scripts/page.js"></script>
  198. </body>
  199. </html>
粤ICP备19079148号