| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Matrix2 - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <h1 translate="no">Matrix2</h1>
- <section>
- <header>
- <div class="class-description"><p>Represents a 2x2 matrix.</p>
- <p>A Note on Row-Major and Column-Major Ordering:</p>
- <p>The constructor and <a href="Matrix2.html#set">Matrix2#set</a> method take arguments in
- <a href="https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order" target="_blank" rel="noopener">row-major</a>
- order, while internally they are stored in the <a href="Matrix2.html#elements">Matrix2#elements</a> array in column-major order.
- This means that calling:</p>
- <p>will result in the elements array containing:</p>
- <pre><code class="language-js">m.elements = [ 11, 21,
- 12, 22 ];
- </code></pre>
- <p>and internally all calculations are performed using column-major ordering.
- However, as the actual ordering makes no difference mathematically and
- most people are used to thinking about matrices in row-major order, the
- three.js documentation shows matrices in row-major order. Just bear in
- mind that if you are reading the source code, you'll have to take the
- transpose of any matrices outlined here to make sense of the calculations.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">const m = new THREE.Matrix2();
- m.set( 11, 12,
- 21, 22 );
- </code></pre></div>
- </header>
- <article>
- <div class="container-overview">
- <h2>Constructor</h2>
- <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>
- <div class="method">
- <div class="description">
- <p>Constructs a new 2x2 matrix. The arguments are supposed to be
- in row-major order. If no arguments are provided, the constructor
- initializes the matrix as an identity matrix.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>n11</strong>
- </td>
- <td class="description last">
- <p>1-1 matrix element.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>n12</strong>
- </td>
- <td class="description last">
- <p>1-2 matrix element.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>n21</strong>
- </td>
- <td class="description last">
- <p>2-1 matrix element.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>n22</strong>
- </td>
- <td class="description last">
- <p>2-2 matrix element.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Classes</h2>
- <dl>
- <dt><a href="Matrix2.html">Matrix2</a></dt>
- <dd></dd>
- </dl>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="elements" translate="no">.<a href="#elements">elements</a><span class="type-signature"> : Array.<number></span> </h3>
- <div class="description">
- <p>A column-major list of matrix values.</p>
- </div>
- </div>
- <div class="member">
- <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>
- <div class="description">
- <p>This flag can be used for type testing.</p>
- <p>Default is <code>true</code>.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="fromArray" translate="no">.<a href="#fromArray">fromArray</a><span class="signature">( array : <span class="param-type">Array.<number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Matrix2.html">Matrix2</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the elements of the matrix from the given array.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>array</strong>
- </td>
- <td class="description last">
- <p>The matrix elements in column-major order.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>offset</strong>
- </td>
- <td class="description last">
- <p>Index of the first element in the array.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets this matrix to the 2x2 identity matrix.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the elements of the matrix.The arguments are supposed to be
- in row-major order.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>n11</strong>
- </td>
- <td class="description last">
- <p>1-1 matrix element.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>n12</strong>
- </td>
- <td class="description last">
- <p>1-2 matrix element.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>n21</strong>
- </td>
- <td class="description last">
- <p>2-1 matrix element.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>n22</strong>
- </td>
- <td class="description last">
- <p>2-2 matrix element.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this matrix.</dt>
- </dl>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <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>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|