1
0

Matrix2.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE html>
  2. <html lang="en">
  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. A class representing a 2x2
  13. [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].
  14. </p>
  15. <h2>Code Example</h2>
  16. <code>
  17. const m = new Matrix2();
  18. </code>
  19. <h2>A Note on Row-Major and Column-Major Ordering</h2>
  20. <p>
  21. The constructor and [page:set]() method take arguments in
  22. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major]
  23. order, while internally they are stored in the [page:.elements elements]
  24. array in column-major order.<br /><br />
  25. This means that calling
  26. <code>
  27. m.set( 11, 12,
  28. 21, 22 );
  29. </code>
  30. will result in the [page:.elements elements] array containing:
  31. <code>
  32. m.elements = [ 11, 21,
  33. 12, 22 ];
  34. </code>
  35. and internally all calculations are performed using column-major ordering.
  36. However, as the actual ordering makes no difference mathematically and
  37. most people are used to thinking about matrices in row-major order, the
  38. three.js documentation shows matrices in row-major order. Just bear in
  39. mind that if you are reading the source code, you'll have to take the
  40. [link:https://en.wikipedia.org/wiki/Transpose transpose] of any matrices
  41. outlined here to make sense of the calculations.
  42. </p>
  43. <h2>Constructor</h2>
  44. <h3>[name]( [param:Number n11], [param:Number n12],
  45. [param:Number n21], [param:Number n22] )</h3>
  46. <p>
  47. Creates a 2x2 matrix with the given arguments in row-major order. If no arguments are provided, the constructor initializes
  48. the [name] to the 3x3 [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
  49. </p>
  50. <h2>Properties</h2>
  51. <h3>[property:Array elements]</h3>
  52. <p>
  53. A [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major] list of matrix values.
  54. </p>
  55. <h2>Methods</h2>
  56. <h3>
  57. [method:this fromArray]( [param:Array array], [param:Integer offset] )
  58. </h3>
  59. <p>
  60. [page:Array array] - the array to read the elements from.<br />
  61. [page:Integer offset] - (optional) index of first element in the array.
  62. Default is `0`.<br /><br />
  63. Sets the elements of this matrix based on an array in
  64. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  65. </p>
  66. <h3>[method:this identity]()</h3>
  67. <p>
  68. Resets this matrix to the 2x2 identity matrix:
  69. </p>
  70. <math display="block">
  71. <mrow>
  72. <mo>[</mo>
  73. <mtable>
  74. <mtr>
  75. <mtd><mn>1</mn></mtd>
  76. <mtd><mn>0</mn></mtd>
  77. </mtr>
  78. <mtr>
  79. <mtd><mn>0</mn></mtd>
  80. <mtd><mn>1</mn></mtd>
  81. </mtr>
  82. </mtable>
  83. <mo>]</mo>
  84. </mrow>
  85. </math>
  86. <h3>
  87. [method:this set]( [param:Float n11], [param:Float n12], [param:Float n21], [param:Float n22] )
  88. </h3>
  89. <p>
  90. Sets the 2x2 matrix values to the given
  91. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major]
  92. sequence of values:
  93. </p>
  94. <math display="block">
  95. <mrow>
  96. <mo>[</mo>
  97. <mtable>
  98. <mtr>
  99. <mtd><mi>n11</mi></mtd>
  100. <mtd><mi>n12</mi></mtd>
  101. </mtr>
  102. <mtr>
  103. <mtd><mi>n21</mi></mtd>
  104. <mtd><mi>n22</mi></mtd>
  105. </mtr>
  106. </mtable>
  107. <mo>]</mo>
  108. </mrow>
  109. </math>
  110. <h2>Source</h2>
  111. <p>
  112. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  113. </p>
  114. </body>
  115. </html>