You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
422 lines
12 KiB
HTML
422 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="it">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<base href="../../../" />
|
|
<script src="page.js"></script>
|
|
<link type="text/css" rel="stylesheet" href="page.css" />
|
|
</head>
|
|
<body>
|
|
<h1>[name]</h1>
|
|
|
|
<p class="desc">
|
|
Una classe che rappresenta una [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrice] 3x3.
|
|
</p>
|
|
|
|
<h2>Codice di Esempio</h2>
|
|
<code>
|
|
const m = new Matrix3();
|
|
</code>
|
|
|
|
<h2>Una nota sull'ordine delle Row-Major (righe principali) e delle Column-Major (colonne principali)</h2>
|
|
<p>
|
|
Il metodo [page:set]() accetta gli argomenti in ordine
|
|
[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major], mentre internamente
|
|
vengono memorizzati nell'array [page:.elements elements] nell'ordine column-major.<br /><br />
|
|
|
|
Ciò significa che la chiamata a
|
|
<code>
|
|
m.set( 11, 12, 13,
|
|
21, 22, 23,
|
|
31, 32, 33 );
|
|
</code>
|
|
risulterà nell'array [page:.elements elements] contenente:
|
|
<code>
|
|
m.elements = [ 11, 21, 31,
|
|
12, 22, 32,
|
|
13, 23, 33 ];
|
|
</code>
|
|
e internamente tutti i calcoli vengono eseguiti utilizzando l'ordine column-major. Tuttavia, poiché l'ordine
|
|
effettivo non fa alcune differenza matematicamente e la maggior parte delle persone è abituata a pensare alle
|
|
matrici nell'ordine row-major, la documentazione di three.js mostra le matrici in ordine di row-major.
|
|
Tieni solo a mente che se stai leggendo il codice sorgente, dovrai prendere la [link:https://en.wikipedia.org/wiki/Transpose trasposizione]
|
|
di tutte le matrici qui descritte per dare un senso ai calcoli.
|
|
</p>
|
|
|
|
<h2>Costruttore</h2>
|
|
|
|
|
|
<h3>[name]( [param:Number n11], [param:Number n12], [param:Number n13],
|
|
[param:Number n21], [param:Number n22], [param:Number n23],
|
|
[param:Number n31], [param:Number n32], [param:Number n33] )</h3>
|
|
<p>
|
|
Creates a 3x3 matrix with the given arguments in row-major. If no arguments are provided, the constructor initializes
|
|
the [name] to the 3x3 [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
|
|
</p>
|
|
|
|
<h2>Proprietà</h2>
|
|
|
|
<h3>[property:Array elements]</h3>
|
|
<p>
|
|
Una lista di [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]
|
|
di valori della matrice.
|
|
</p>
|
|
|
|
<h2>Metodi</h2>
|
|
|
|
<h3>[method:Matrix3 clone]()</h3>
|
|
<p>Crea una Matrix3 con elementi identici a questa.</p>
|
|
|
|
<h3>[method:this copy]( [param:Matrix3 m] )</h3>
|
|
<p>Copia gli elementi della matrice [page:Matrix3 m] in questa matrice.</p>
|
|
|
|
<h3>[method:Float determinant]()</h3>
|
|
<p>
|
|
Calcola e restituisce il [link:https://en.wikipedia.org/wiki/Determinant determinante] di questa matrice.
|
|
</p>
|
|
|
|
<h3>[method:Boolean equals]( [param:Matrix3 m] )</h3>
|
|
<p>Restituisce true se questa matrice e [page:Matrix3 m] sono uguali.</p>
|
|
|
|
<h3>[method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )</h3>
|
|
<p>
|
|
Estrae la [link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) base] di questa matrice
|
|
nei tre vettori asse forniti. Se questa matrice è:
|
|
</p>
|
|
|
|
<math display="block">
|
|
<mrow>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr>
|
|
<mtd><mi>a</mi></mtd>
|
|
<mtd><mi>b</mi></mtd>
|
|
<mtd><mi>c</mi></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mi>d</mi></mtd>
|
|
<mtd><mi>e</mi></mtd>
|
|
<mtd><mi>f</mi></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mi>g</mi></mtd>
|
|
<mtd><mi>h</mi></mtd>
|
|
<mtd><mi>i</mi></mtd>
|
|
</mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>
|
|
|
|
<p>
|
|
allora [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] saranno impostate a:
|
|
</p>
|
|
|
|
<div style="text-align: center">
|
|
<math>
|
|
<mrow>
|
|
<mi>xAxis</mi>
|
|
<mo>=</mo>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr><mtd style="height: 1rem"><mi>a</mi></mtd></mtr>
|
|
<mtr><mtd style="height: 1rem"><mi>d</mi></mtd></mtr>
|
|
<mtr><mtd style="height: 1rem"><mi>g</mi></mtd></mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>,
|
|
|
|
<math>
|
|
<mrow>
|
|
<mi>yAxis</mi>
|
|
<mo>=</mo>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr><mtd style="height: 1rem"><mi>b</mi></mtd></mtr>
|
|
<mtr><mtd style="height: 1rem"><mi>e</mi></mtd></mtr>
|
|
<mtr><mtd style="height: 1rem"><mi>h</mi></mtd></mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>, and
|
|
|
|
<math>
|
|
<mrow>
|
|
<mi>zAxis</mi>
|
|
<mo>=</mo>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr><mtd style="height: 1rem"><mi>c</mi></mtd></mtr>
|
|
<mtr><mtd style="height: 1rem"><mi>f</mi></mtd></mtr>
|
|
<mtr><mtd style="height: 1rem"><mi>i</mi></mtd></mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>
|
|
</div>
|
|
|
|
<h3>[method:this fromArray]( [param:Array array], [param:Integer offset] )</h3>
|
|
<p>
|
|
[page:Array array] - l'array da cui leggere gli elementi.<br />
|
|
[page:Integer offset] - (opzionale) indice del primo elemento nell'array. Il valore predefinito è 0.<br /><br />
|
|
|
|
Imposta gli elementi di questa matrice in base ad un array nel formato
|
|
[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major].
|
|
</p>
|
|
|
|
<h3>[method:this invert]()</h3>
|
|
<p>
|
|
Inverte questa matrice, utilizzando il [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution metodo analitico].
|
|
|
|
Non puoi invertire con un determinante zero. Se si tenta questo, il metodo produce invece una matrice zero.
|
|
</p>
|
|
|
|
<h3>[method:this getNormalMatrix]( [param:Matrix4 m] )</h3>
|
|
<p>
|
|
[page:Matrix4 m] - [page:Matrix4]<br /><br />
|
|
|
|
Imposta questa matrice come 3x3 in alto a sinistra della [link:https://en.wikipedia.org/wiki/Normal_matrix matrice normale]
|
|
della [page:Matrix4 matrix4] passata. La matrice normale è la [link:https://en.wikipedia.org/wiki/Transpose trasposta]
|
|
[link:https://en.wikipedia.org/wiki/Invertible_matrix inversa] della matrice [page:Matrix4 m].
|
|
</p>
|
|
|
|
<h3>[method:this identity]()</h3>
|
|
<p>
|
|
Reimposta questa matrice alla matrice identità 3x3:
|
|
</p>
|
|
|
|
<math display="block">
|
|
<mrow>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr>
|
|
<mtd><mn>1</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>1</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>1</mn></mtd>
|
|
</mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>
|
|
|
|
<h3>[method:this makeRotation]( [param:Float theta] )</h3>
|
|
<p>
|
|
[page:Float theta] — Angolo di rotazione in radianti. I valori positivi ruotano in senso antiorario.<br /><br />
|
|
|
|
Imposta questa matrice come una trasformazione rotazionale 2D di [page:Float teta] radianti.
|
|
La matrice risultante sarà:
|
|
</p>
|
|
|
|
<math display="block">
|
|
<mrow>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr>
|
|
<mtd>
|
|
<mi>cos</mi>
|
|
<mi>θ</mi>
|
|
</mtd>
|
|
<mtd>
|
|
<mi>-sin</mi>
|
|
<mi>θ</mi>
|
|
</mtd>
|
|
<mtd>
|
|
<mn>0</mn>
|
|
</mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd>
|
|
<mi>sin</mi>
|
|
<mi>θ</mi>
|
|
</mtd>
|
|
<mtd>
|
|
<mi>cos</mi>
|
|
<mi>θ</mi>
|
|
</mtd>
|
|
<mtd>
|
|
<mn>0</mn>
|
|
</mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>1</mn></mtd>
|
|
</mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>
|
|
|
|
<h3>[method:this makeScale]( [param:Float x], [param:Float y] )</h3>
|
|
<p>
|
|
[page:Float x] - la quantità da scalare sull'asse X.<br />
|
|
[page:Float y] - la quantità da scalare sull'asse Y.<br />
|
|
|
|
Imposta questa matrice come una trasformazione di scala 2D:
|
|
</p>
|
|
|
|
<math display="block">
|
|
<mrow>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr>
|
|
<mtd><mi>x</mi></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mi>y</mi></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>1</mn></mtd>
|
|
</mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>
|
|
|
|
<h3>[method:this makeTranslation]( [param:Vector2 v] )</h3>
|
|
<h3>[method:this makeTranslation]( [param:Float x], [param:Float y] )</h3>
|
|
<p>
|
|
[page:Vector2 v] a translation transform from vector.<br />
|
|
or<br />
|
|
[page:Float x] - la quantità da translare sull'asse X.<br />
|
|
[page:Float y] - la quantità da translare sull'asse Y.<br />
|
|
|
|
Imposta questa matrice come una trasformazione di traslazione 2D:
|
|
</p>
|
|
|
|
<math display="block">
|
|
<mrow>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr>
|
|
<mtd><mn>1</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mi>x</mi></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>1</mn></mtd>
|
|
<mtd><mi>y</mi></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>0</mn></mtd>
|
|
<mtd><mn>1</mn></mtd>
|
|
</mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>
|
|
|
|
<h3>[method:this multiply]( [param:Matrix3 m] )</h3>
|
|
<p>Post-moltiplica questa matrice per [page:Matrix3 m].</p>
|
|
|
|
<h3>[method:this multiplyMatrices]( [param:Matrix3 a], [param:Matrix3 b] )</h3>
|
|
<p>Imposta questa matrice ad [page:Matrix3 a] x [page:Matrix3 b].</p>
|
|
|
|
<h3>[method:this multiplyScalar]( [param:Float s] )</h3>
|
|
<p>Moltiplica ogni componente della matrice per il valore scalare *s*.</p>
|
|
|
|
<h3>[method:this rotate]( [param:Float theta] )</h3>
|
|
<p>Ruota questa matrice dell'angolo dato (in radianti).</p>
|
|
|
|
<h3>[method:this scale]( [param:Float sx], [param:Float sy] )</h3>
|
|
<p>Ridimensiona questa matrice dei valori scalari passati.</p>
|
|
|
|
<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>
|
|
<p>
|
|
Imposta i valori della matrice 3x3 sulla sequenza di valori della
|
|
[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major] specificata.
|
|
</p>
|
|
|
|
<math display="block">
|
|
<mrow>
|
|
<mo>[</mo>
|
|
<mtable>
|
|
<mtr>
|
|
<mtd><mi>n11</mi></mtd>
|
|
<mtd><mi>n12</mi></mtd>
|
|
<mtd><mi>n13</mi></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mi>n21</mi></mtd>
|
|
<mtd><mi>n22</mi></mtd>
|
|
<mtd><mi>n23</mi></mtd>
|
|
</mtr>
|
|
<mtr>
|
|
<mtd><mi>n31</mi></mtd>
|
|
<mtd><mi>n32</mi></mtd>
|
|
<mtd><mi>n33</mi></mtd>
|
|
</mtr>
|
|
</mtable>
|
|
<mo>]</mo>
|
|
</mrow>
|
|
</math>
|
|
|
|
<h3>[method:this premultiply]( [param:Matrix3 m] )</h3>
|
|
<p>Pre-moltiplica questa matrice per [page:Matrix3 m].</p>
|
|
|
|
<h3>[method:this setFromMatrix4]( [param:Matrix4 m] )</h3>
|
|
<p>Imposta questa matrice sulla matrice 3x3 superiore di Matrix4 [page:Matrix4 m].</p>
|
|
|
|
<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>
|
|
<p>
|
|
[page:Float tx] - offset x<br />
|
|
[page:Float ty] - offset y<br />
|
|
[page:Float sx] - repeat x<br />
|
|
[page:Float sy] - repeat y<br />
|
|
[page:Float rotation] - rotazione, in radianti. I valori positivi ruotano in senso antiorario<br />
|
|
[page:Float cx] - centro x di rotazione<br />
|
|
[page:Float cy] - centro y di rotazione<br /><br />
|
|
|
|
Imposta la matrice di trasformazione UV da offset, ripetizione, rotazione e centro.
|
|
</p>
|
|
|
|
<h3>[method:Array toArray]( [param:Array array], [param:Integer offset] )</h3>
|
|
<p>
|
|
[page:Array array] - (opzionale) array per memorizzare il vettore risultante. In caso contrario, verrà creato un nuovo array.<br />
|
|
[page:Integer offset] - (opzionale) offset nell'array in cui inserire il risultato.<br /><br />
|
|
|
|
Scrive gli elementi di questa matrice in una matrice in formato
|
|
[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major].
|
|
</p>
|
|
|
|
<h3>[method:this translate]( [param:Float tx], [param:Float ty] )</h3>
|
|
<p>Trasla questa matrice dei valori scalari dati.</p>
|
|
|
|
<h3>[method:this transpose]()</h3>
|
|
<p>[link:https://en.wikipedia.org/wiki/Transpose Traspone] questa matrice al suo posto.</p>
|
|
|
|
<h3>[method:this transposeIntoArray]( [param:Array array] )</h3>
|
|
<p>
|
|
[page:Array array] - array per memorizzare il vettore risultante.<br /><br />
|
|
|
|
[link:https://en.wikipedia.org/wiki/Transpose Traspone] questa matrice nell'array fornito,
|
|
e ritorna immutato.
|
|
</p>
|
|
|
|
<h2>Source</h2>
|
|
|
|
<p>
|
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
|
</p>
|
|
</body>
|
|
</html>
|