Matrix3.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <!DOCTYPE html>
  2. <html lang="it">
  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. Una classe che rappresenta una [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrice] 3x3.
  13. </p>
  14. <h2>Codice di Esempio</h2>
  15. <code>
  16. const m = new Matrix3();
  17. </code>
  18. <h2>Una nota sull'ordine delle Row-Major (righe principali) e delle Column-Major (colonne principali)</h2>
  19. <p>
  20. Il metodo [page:set]() accetta gli argomenti in ordine
  21. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major], mentre internamente
  22. vengono memorizzati nell'array [page:.elements elements] nell'ordine column-major.<br /><br />
  23. Ciò significa che la chiamata a
  24. <code>
  25. m.set( 11, 12, 13,
  26. 21, 22, 23,
  27. 31, 32, 33 );
  28. </code>
  29. risulterà nell'array [page:.elements elements] contenente:
  30. <code>
  31. m.elements = [ 11, 21, 31,
  32. 12, 22, 32,
  33. 13, 23, 33 ];
  34. </code>
  35. e internamente tutti i calcoli vengono eseguiti utilizzando l'ordine column-major. Tuttavia, poiché l'ordine
  36. effettivo non fa alcune differenza matematicamente e la maggior parte delle persone è abituata a pensare alle
  37. matrici nell'ordine row-major, la documentazione di three.js mostra le matrici in ordine di row-major.
  38. Tieni solo a mente che se stai leggendo il codice sorgente, dovrai prendere la [link:https://en.wikipedia.org/wiki/Transpose trasposizione]
  39. di tutte le matrici qui descritte per dare un senso ai calcoli.
  40. </p>
  41. <h2>Costruttore</h2>
  42. <h3>[name]( [param:Number n11], [param:Number n12], [param:Number n13],
  43. [param:Number n21], [param:Number n22], [param:Number n23],
  44. [param:Number n31], [param:Number n32], [param:Number n33] )</h3>
  45. <p>
  46. Creates a 3x3 matrix with the given arguments in row-major. If no arguments are provided, the constructor initializes
  47. the [name] to the 3x3 [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
  48. </p>
  49. <h2>Proprietà</h2>
  50. <h3>[property:Array elements]</h3>
  51. <p>
  52. Una lista di [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]
  53. di valori della matrice.
  54. </p>
  55. <h2>Metodi</h2>
  56. <h3>[method:Matrix3 clone]()</h3>
  57. <p>Crea una Matrix3 con elementi identici a questa.</p>
  58. <h3>[method:this copy]( [param:Matrix3 m] )</h3>
  59. <p>Copia gli elementi della matrice [page:Matrix3 m] in questa matrice.</p>
  60. <h3>[method:Float determinant]()</h3>
  61. <p>
  62. Calcola e restituisce il [link:https://en.wikipedia.org/wiki/Determinant determinante] di questa matrice.
  63. </p>
  64. <h3>[method:Boolean equals]( [param:Matrix3 m] )</h3>
  65. <p>Restituisce true se questa matrice e [page:Matrix3 m] sono uguali.</p>
  66. <h3>[method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )</h3>
  67. <p>
  68. Estrae la [link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) base] di questa matrice
  69. nei tre vettori asse forniti. Se questa matrice è:<br /><br />
  70. <math>
  71. <mrow>
  72. <mo>[</mo>
  73. <mtable>
  74. <mtr>
  75. <mtd><mi>a</mi></mtd>
  76. <mtd><mi>b</mi></mtd>
  77. <mtd><mi>c</mi></mtd>
  78. </mtr>
  79. <mtr>
  80. <mtd><mi>d</mi></mtd>
  81. <mtd><mi>e</mi></mtd>
  82. <mtd><mi>f</mi></mtd>
  83. </mtr>
  84. <mtr>
  85. <mtd><mi>g</mi></mtd>
  86. <mtd><mi>h</mi></mtd>
  87. <mtd><mi>i</mi></mtd>
  88. </mtr>
  89. </mtable>
  90. <mo>]</mo>
  91. </mrow>
  92. </math><br /><br />
  93. allora [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] saranno impostate a:<br /><br />
  94. <math>
  95. <mrow>
  96. <mi>xAxis</mi>
  97. <mo>=</mo>
  98. <mo>[</mo>
  99. <mtable>
  100. <mtr><mtd style="height: 1rem"><mi>a</mi></mtd></mtr>
  101. <mtr><mtd style="height: 1rem"><mi>d</mi></mtd></mtr>
  102. <mtr><mtd style="height: 1rem"><mi>g</mi></mtd></mtr>
  103. </mtable>
  104. <mo>]</mo>
  105. </mrow>
  106. </math>,
  107. <math>
  108. <mrow>
  109. <mi>yAxis</mi>
  110. <mo>=</mo>
  111. <mo>[</mo>
  112. <mtable>
  113. <mtr><mtd style="height: 1rem"><mi>b</mi></mtd></mtr>
  114. <mtr><mtd style="height: 1rem"><mi>e</mi></mtd></mtr>
  115. <mtr><mtd style="height: 1rem"><mi>h</mi></mtd></mtr>
  116. </mtable>
  117. <mo>]</mo>
  118. </mrow>
  119. </math>, and
  120. <math>
  121. <mrow>
  122. <mi>zAxis</mi>
  123. <mo>=</mo>
  124. <mo>[</mo>
  125. <mtable>
  126. <mtr><mtd style="height: 1rem"><mi>c</mi></mtd></mtr>
  127. <mtr><mtd style="height: 1rem"><mi>f</mi></mtd></mtr>
  128. <mtr><mtd style="height: 1rem"><mi>i</mi></mtd></mtr>
  129. </mtable>
  130. <mo>]</mo>
  131. </mrow>
  132. </math>
  133. </p>
  134. <h3>[method:this fromArray]( [param:Array array], [param:Integer offset] )</h3>
  135. <p>
  136. [page:Array array] - l'array da cui leggere gli elementi.<br />
  137. [page:Integer offset] - (opzionale) indice del primo elemento nell'array. Il valore predefinito è 0.<br /><br />
  138. Imposta gli elementi di questa matrice in base ad un array nel formato
  139. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major].
  140. </p>
  141. <h3>[method:this invert]()</h3>
  142. <p>
  143. Inverte questa matrice, utilizzando il [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution metodo analitico].
  144. Non puoi invertire con un determinante zero. Se si tenta questo, il metodo produce invece una matrice zero.
  145. </p>
  146. <h3>[method:this getNormalMatrix]( [param:Matrix4 m] )</h3>
  147. <p>
  148. [page:Matrix4 m] - [page:Matrix4]<br /><br />
  149. Imposta questa matrice come 3x3 in alto a sinistra della [link:https://en.wikipedia.org/wiki/Normal_matrix matrice normale]
  150. della [page:Matrix4 matrix4] passata. La matrice normale è la [link:https://en.wikipedia.org/wiki/Transpose trasposta]
  151. [link:https://en.wikipedia.org/wiki/Invertible_matrix inversa] della matrice [page:Matrix4 m].
  152. </p>
  153. <h3>[method:this identity]()</h3>
  154. <p>
  155. Reimposta questa matrice alla matrice identità 3x3:<br /><br />
  156. <math>
  157. <mrow>
  158. <mo>[</mo>
  159. <mtable>
  160. <mtr>
  161. <mtd><mn>1</mn></mtd>
  162. <mtd><mn>0</mn></mtd>
  163. <mtd><mn>0</mn></mtd>
  164. </mtr>
  165. <mtr>
  166. <mtd><mn>0</mn></mtd>
  167. <mtd><mn>1</mn></mtd>
  168. <mtd><mn>0</mn></mtd>
  169. </mtr>
  170. <mtr>
  171. <mtd><mn>0</mn></mtd>
  172. <mtd><mn>0</mn></mtd>
  173. <mtd><mn>1</mn></mtd>
  174. </mtr>
  175. </mtable>
  176. <mo>]</mo>
  177. </mrow>
  178. </math>
  179. </p>
  180. <h3>[method:this makeRotation]( [param:Float theta] )</h3>
  181. <p>
  182. [page:Float theta] — Angolo di rotazione in radianti. I valori positivi ruotano in senso antiorario.<br /><br />
  183. Imposta questa matrice come una trasformazione rotazionale 2D di [page:Float teta] radianti.
  184. La matrice risultante sarà:<br /><br />
  185. <math>
  186. <mrow>
  187. <mo>[</mo>
  188. <mtable>
  189. <mtr>
  190. <mtd>
  191. <mi>cos</mi>
  192. <mi>&theta;</mi>
  193. </mtd>
  194. <mtd>
  195. <mi>-sin</mi>
  196. <mi>&theta;</mi>
  197. </mtd>
  198. <mtd>
  199. <mn>0</mn>
  200. </mtd>
  201. </mtr>
  202. <mtr>
  203. <mtd>
  204. <mi>sin</mi>
  205. <mi>&theta;</mi>
  206. </mtd>
  207. <mtd>
  208. <mi>cos</mi>
  209. <mi>&theta;</mi>
  210. </mtd>
  211. <mtd>
  212. <mn>0</mn>
  213. </mtd>
  214. </mtr>
  215. <mtr>
  216. <mtd><mn>0</mn></mtd>
  217. <mtd><mn>0</mn></mtd>
  218. <mtd><mn>1</mn></mtd>
  219. </mtr>
  220. </mtable>
  221. <mo>]</mo>
  222. </mrow>
  223. </math>
  224. </p>
  225. <h3>[method:this makeScale]( [param:Float x], [param:Float y] )</h3>
  226. <p>
  227. [page:Float x] - la quantità da scalare sull'asse X.<br />
  228. [page:Float y] - la quantità da scalare sull'asse Y.<br />
  229. Imposta questa matrice come una trasformazione di scala 2D:<br /><br />
  230. <math>
  231. <mrow>
  232. <mo>[</mo>
  233. <mtable>
  234. <mtr>
  235. <mtd><mi>x</mi></mtd>
  236. <mtd><mn>0</mn></mtd>
  237. <mtd><mn>0</mn></mtd>
  238. </mtr>
  239. <mtr>
  240. <mtd><mn>0</mn></mtd>
  241. <mtd><mi>y</mi></mtd>
  242. <mtd><mn>0</mn></mtd>
  243. </mtr>
  244. <mtr>
  245. <mtd><mn>0</mn></mtd>
  246. <mtd><mn>0</mn></mtd>
  247. <mtd><mn>1</mn></mtd>
  248. </mtr>
  249. </mtable>
  250. <mo>]</mo>
  251. </mrow>
  252. </math>
  253. </p>
  254. <h3>[method:this makeTranslation]( [param:Vector2 v] )</h3>
  255. <h3>[method:this makeTranslation]( [param:Float x], [param:Float y] )</h3>
  256. <p>
  257. [page:Vector2 v] a translation transform from vector.<br />
  258. or<br />
  259. [page:Float x] - la quantità da translare sull'asse X.<br />
  260. [page:Float y] - la quantità da translare sull'asse Y.<br />
  261. Imposta questa matrice come una trasformazione di traslazione 2D:<br /><br />
  262. <math>
  263. <mrow>
  264. <mo>[</mo>
  265. <mtable>
  266. <mtr>
  267. <mtd><mn>1</mn></mtd>
  268. <mtd><mn>0</mn></mtd>
  269. <mtd><mi>x</mi></mtd>
  270. </mtr>
  271. <mtr>
  272. <mtd><mn>0</mn></mtd>
  273. <mtd><mn>1</mn></mtd>
  274. <mtd><mi>y</mi></mtd>
  275. </mtr>
  276. <mtr>
  277. <mtd><mn>0</mn></mtd>
  278. <mtd><mn>0</mn></mtd>
  279. <mtd><mn>1</mn></mtd>
  280. </mtr>
  281. </mtable>
  282. <mo>]</mo>
  283. </mrow>
  284. </math>
  285. </p>
  286. <h3>[method:this multiply]( [param:Matrix3 m] )</h3>
  287. <p>Post-moltiplica questa matrice per [page:Matrix3 m].</p>
  288. <h3>[method:this multiplyMatrices]( [param:Matrix3 a], [param:Matrix3 b] )</h3>
  289. <p>Imposta questa matrice ad [page:Matrix3 a] x [page:Matrix3 b].</p>
  290. <h3>[method:this multiplyScalar]( [param:Float s] )</h3>
  291. <p>Moltiplica ogni componente della matrice per il valore scalare *s*.</p>
  292. <h3>[method:this rotate]( [param:Float theta] )</h3>
  293. <p>Ruota questa matrice dell'angolo dato (in radianti).</p>
  294. <h3>[method:this scale]( [param:Float sx], [param:Float sy] )</h3>
  295. <p>Ridimensiona questa matrice dei valori scalari passati.</p>
  296. <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>
  297. <p>
  298. Imposta i valori della matrice 3x3 sulla sequenza di valori della
  299. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major] specificata.<br /><br />
  300. <math>
  301. <mrow>
  302. <mo>[</mo>
  303. <mtable>
  304. <mtr>
  305. <mtd><mi>n11</mi></mtd>
  306. <mtd><mi>n12</mi></mtd>
  307. <mtd><mi>n13</mi></mtd>
  308. </mtr>
  309. <mtr>
  310. <mtd><mi>n21</mi></mtd>
  311. <mtd><mi>n22</mi></mtd>
  312. <mtd><mi>n23</mi></mtd>
  313. </mtr>
  314. <mtr>
  315. <mtd><mi>n31</mi></mtd>
  316. <mtd><mi>n32</mi></mtd>
  317. <mtd><mi>n33</mi></mtd>
  318. </mtr>
  319. </mtable>
  320. <mo>]</mo>
  321. </mrow>
  322. </math>
  323. </p>
  324. <h3>[method:this premultiply]( [param:Matrix3 m] )</h3>
  325. <p>Pre-moltiplica questa matrice per [page:Matrix3 m].</p>
  326. <h3>[method:this setFromMatrix4]( [param:Matrix4 m] )</h3>
  327. <p>Imposta questa matrice sulla matrice 3x3 superiore di Matrix4 [page:Matrix4 m].</p>
  328. <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>
  329. <p>
  330. [page:Float tx] - offset x<br />
  331. [page:Float ty] - offset y<br />
  332. [page:Float sx] - repeat x<br />
  333. [page:Float sy] - repeat y<br />
  334. [page:Float rotation] - rotazione, in radianti. I valori positivi ruotano in senso antiorario<br />
  335. [page:Float cx] - centro x di rotazione<br />
  336. [page:Float cy] - centro y di rotazione<br /><br />
  337. Imposta la matrice di trasformazione UV da offset, ripetizione, rotazione e centro.
  338. </p>
  339. <h3>[method:Array toArray]( [param:Array array], [param:Integer offset] )</h3>
  340. <p>
  341. [page:Array array] - (opzionale) array per memorizzare il vettore risultante. In caso contrario, verrà creato un nuovo array.<br />
  342. [page:Integer offset] - (opzionale) offset nell'array in cui inserire il risultato.<br /><br />
  343. Scrive gli elementi di questa matrice in una matrice in formato
  344. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major].
  345. </p>
  346. <h3>[method:this translate]( [param:Float tx], [param:Float ty] )</h3>
  347. <p>Trasla questa matrice dei valori scalari dati.</p>
  348. <h3>[method:this transpose]()</h3>
  349. <p>[link:https://en.wikipedia.org/wiki/Transpose Traspone] questa matrice al suo posto.</p>
  350. <h3>[method:this transposeIntoArray]( [param:Array array] )</h3>
  351. <p>
  352. [page:Array array] - array per memorizzare il vettore risultante.<br /><br />
  353. [link:https://en.wikipedia.org/wiki/Transpose Traspone] questa matrice nell'array fornito,
  354. e ritorna immutato.
  355. </p>
  356. <h2>Source</h2>
  357. <p>
  358. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  359. </p>
  360. </body>
  361. </html>