Matrix3.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>三维矩阵([name])</h1>
  11. <p class="desc">
  12. 一个表示3X3矩阵[link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].的类。
  13. </p>
  14. <h2>代码示例</h2>
  15. <code>
  16. const m = new Matrix3();
  17. </code>
  18. <h2>注意行优先列优先的顺序。</h2>
  19. <p>
  20. [page:set]()方法参数采用行优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major],
  21. 而它们在内部是用列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]顺序存储在数组当中。<br /><br />
  22. 这意味着
  23. <code>
  24. m.set( 11, 12, 13,
  25. 21, 22, 23,
  26. 31, 32, 33 );
  27. </code>
  28. 元素数组[page:.elements elements]将存储为:
  29. <code>
  30. m.elements = [ 11, 21, 31,
  31. 12, 22, 32,
  32. 13, 23, 33 ];
  33. </code>
  34. 在内部,所有的计算都是使用列优先顺序进行的。然而,由于实际的排序在数学上没有什么不同,
  35. 而且大多数人习惯于以行优先顺序考虑矩阵,所以three.js文档以行为主的顺序显示矩阵。
  36. 请记住,如果您正在阅读源代码,您必须对这里列出的任何矩阵进行转置[link:https://en.wikipedia.org/wiki/Transpose transpose],以理解计算。
  37. </p>
  38. <h2>Constructor</h2>
  39. <h3>[name]()</h3>
  40. <p>
  41. 创建并初始化一个3X3的单位矩阵[link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
  42. </p>
  43. <h2>属性(Properties)</h2>
  44. <h3>[property:Array elements]</h3>
  45. <p>
  46. 矩阵列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]列表。
  47. </p>
  48. <h2>方法(Methods)</h2>
  49. <h3>[method:Matrix3 clone]()</h3>
  50. <p>创建一个新的矩阵,元素 [page:.elements elements] 与该矩阵相同。</p>
  51. <h3>[method:this copy]( [param:Matrix3 m] )</h3>
  52. <p>将矩阵[page:Matrix3 m]的元素复制到当前矩阵中。</p>
  53. <h3>[method:Float determinant]()</h3>
  54. <p>
  55. 计算并返回矩阵的行列式[link:https://en.wikipedia.org/wiki/Determinant determinant] 。
  56. </p>
  57. <h3>[method:Boolean equals]( [param:Matrix3 m] )</h3>
  58. <p>如果矩阵[page:Matrix3 m] 与当前矩阵所有对应元素相同则返回true。</p>
  59. <h3>[method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )</h3>
  60. <p>
  61. Extracts the [link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis] of this
  62. matrix into the three axis vectors provided. If this matrix is:
  63. <code>
  64. a, b, c,
  65. d, e, f,
  66. g, h, i
  67. </code>
  68. then the [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] will be set to:
  69. <code>
  70. xAxis = (a, d, g)
  71. yAxis = (b, e, h)
  72. zAxis = (c, f, i)
  73. </code>
  74. </p>
  75. <h3>[method:this fromArray]( [param:Array array], [param:Integer offset] )</h3>
  76. <p>
  77. [page:Array array] - 用来存储设置元素数据的数组<br />
  78. [page:Integer offset] - (可选参数) 数组的偏移量,默认值为 0。<br /><br />
  79. 使用基于列优先格式[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]的数组来设置该矩阵。
  80. </p>
  81. <h3>[method:this invert]()</h3>
  82. <p>
  83. Inverts this matrix, using the [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method].
  84. You can not invert with a determinant of zero. If you attempt this, the method produces a zero matrix instead.
  85. </p>
  86. <h3>[method:this getNormalMatrix]( [param:Matrix4 m] )</h3>
  87. <p>
  88. [page:Matrix4 m] - [page:Matrix4]<br /><br />
  89. 将这个矩阵设置为给定矩阵的正规矩阵[link:https://en.wikipedia.org/wiki/Normal_matrix normal matrix](左上角的3x3)。
  90. 正规矩阵是矩阵[page:Matrix4 m]的逆矩阵[link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] 的转置[link:https://en.wikipedia.org/wiki/Transpose transpose]。
  91. </p>
  92. <h3>[method:this identity]()</h3>
  93. <p>
  94. 将此矩阵重置为3x3单位矩阵:
  95. <code>
  96. 1, 0, 0
  97. 0, 1, 0
  98. 0, 0, 1
  99. </code>
  100. </p>
  101. <h3>[method:this multiply]( [param:Matrix3 m] )</h3>
  102. <p>将当前矩阵乘以矩阵[page:Matrix3 m]。</p>
  103. <h3>[method:this multiplyMatrices]( [param:Matrix3 a], [param:Matrix3 b] )</h3>
  104. <p>设置当前矩阵为矩阵[page:Matrix3 a] x 矩阵[page:Matrix3 b]。</p>
  105. <h3>[method:this multiplyScalar]( [param:Float s] )</h3>
  106. <p>当前矩阵所有的元素乘以该缩放值*s*</p>
  107. <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>
  108. <p>
  109. [page:Float n11] - 设置第一行第一列的值。<br />
  110. [page:Float n12] - 设置第一行第二列的值。<br />
  111. ...<br />
  112. ...<br />
  113. [page:Float n32] - 设置第三行第二列的值。<br />
  114. [page:Float n33] - 设置第三行第三列的值。<br /><br />
  115. Sets the 3x3 matrix values to the given
  116. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major]
  117. sequence of values.
  118. </p>
  119. <h3>[method:this premultiply]( [param:Matrix3 m] )</h3>
  120. <p>将矩阵[page:Matrix3 m]乘以当前矩阵。</p>
  121. <h3>[method:this setFromMatrix4]( [param:Matrix4 m] )</h3>
  122. <p>将当前矩阵设置为4X4矩阵[page:Matrix4 m]左上3X3</p>
  123. <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>
  124. <p>
  125. [page:Float tx] - x偏移量<br />
  126. [page:Float ty] - y偏移量<br />
  127. [page:Float sx] - x方向的重复比例<br />
  128. [page:Float sy] - y方向的重复比例<br />
  129. [page:Float rotation] - 旋转(弧度)<br />
  130. [page:Float cx] - 旋转中心x<br />
  131. [page:Float cy] - 旋转中心y<br /><br />
  132. 使用偏移,重复,旋转和中心点位置设置UV变换矩阵。
  133. </p>
  134. <h3>[method:Array toArray]( [param:Array array], [param:Integer offset] )</h3>
  135. <p>
  136. [page:Array array] - (可选参数) 存储矩阵元素的数组,如果未指定会创建一个新的数组。<br />
  137. [page:Integer offset] - (可选参数) 存放矩阵元素数组的偏移量。<br /><br />
  138. 使用列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]格式将此矩阵的元素写入数组中。
  139. </p>
  140. <h3>[method:this transpose]()</h3>
  141. <p>将该矩阵转置[link:https://en.wikipedia.org/wiki/Transpose Transposes]。</p>
  142. <h3>[method:this transposeIntoArray]( [param:Array array] )</h3>
  143. <p>
  144. [page:Array array] - 用于存储当前矩阵转置结果的数组。<br /><br />
  145. 将当前矩阵的转置[link:https://en.wikipedia.org/wiki/Transpose Transposes]存入给定的数组[param:Array array]但不改变当前矩阵,
  146. 并返回当前矩阵。
  147. </p>
  148. <h2>源码(Source)</h2>
  149. <p>
  150. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  151. </p>
  152. </body>
  153. </html>