Matrix3.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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 è:
  70. </p>
  71. <math display="block">
  72. <mrow>
  73. <mo>[</mo>
  74. <mtable>
  75. <mtr>
  76. <mtd><mi>a</mi></mtd>
  77. <mtd><mi>b</mi></mtd>
  78. <mtd><mi>c</mi></mtd>
  79. </mtr>
  80. <mtr>
  81. <mtd><mi>d</mi></mtd>
  82. <mtd><mi>e</mi></mtd>
  83. <mtd><mi>f</mi></mtd>
  84. </mtr>
  85. <mtr>
  86. <mtd><mi>g</mi></mtd>
  87. <mtd><mi>h</mi></mtd>
  88. <mtd><mi>i</mi></mtd>
  89. </mtr>
  90. </mtable>
  91. <mo>]</mo>
  92. </mrow>
  93. </math>
  94. <p>
  95. allora [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] saranno impostate a:
  96. </p>
  97. <div style="text-align: center">
  98. <math>
  99. <mrow>
  100. <mi>xAxis</mi>
  101. <mo>=</mo>
  102. <mo>[</mo>
  103. <mtable>
  104. <mtr><mtd style="height: 1rem"><mi>a</mi></mtd></mtr>
  105. <mtr><mtd style="height: 1rem"><mi>d</mi></mtd></mtr>
  106. <mtr><mtd style="height: 1rem"><mi>g</mi></mtd></mtr>
  107. </mtable>
  108. <mo>]</mo>
  109. </mrow>
  110. </math>,
  111. <math>
  112. <mrow>
  113. <mi>yAxis</mi>
  114. <mo>=</mo>
  115. <mo>[</mo>
  116. <mtable>
  117. <mtr><mtd style="height: 1rem"><mi>b</mi></mtd></mtr>
  118. <mtr><mtd style="height: 1rem"><mi>e</mi></mtd></mtr>
  119. <mtr><mtd style="height: 1rem"><mi>h</mi></mtd></mtr>
  120. </mtable>
  121. <mo>]</mo>
  122. </mrow>
  123. </math>, and
  124. <math>
  125. <mrow>
  126. <mi>zAxis</mi>
  127. <mo>=</mo>
  128. <mo>[</mo>
  129. <mtable>
  130. <mtr><mtd style="height: 1rem"><mi>c</mi></mtd></mtr>
  131. <mtr><mtd style="height: 1rem"><mi>f</mi></mtd></mtr>
  132. <mtr><mtd style="height: 1rem"><mi>i</mi></mtd></mtr>
  133. </mtable>
  134. <mo>]</mo>
  135. </mrow>
  136. </math>
  137. </div>
  138. <h3>[method:this fromArray]( [param:Array array], [param:Integer offset] )</h3>
  139. <p>
  140. [page:Array array] - l'array da cui leggere gli elementi.<br />
  141. [page:Integer offset] - (opzionale) indice del primo elemento nell'array. Il valore predefinito è 0.<br /><br />
  142. Imposta gli elementi di questa matrice in base ad un array nel formato
  143. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major].
  144. </p>
  145. <h3>[method:this invert]()</h3>
  146. <p>
  147. Inverte questa matrice, utilizzando il [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution metodo analitico].
  148. Non puoi invertire con un determinante zero. Se si tenta questo, il metodo produce invece una matrice zero.
  149. </p>
  150. <h3>[method:this getNormalMatrix]( [param:Matrix4 m] )</h3>
  151. <p>
  152. [page:Matrix4 m] - [page:Matrix4]<br /><br />
  153. Imposta questa matrice come 3x3 in alto a sinistra della [link:https://en.wikipedia.org/wiki/Normal_matrix matrice normale]
  154. della [page:Matrix4 matrix4] passata. La matrice normale è la [link:https://en.wikipedia.org/wiki/Transpose trasposta]
  155. [link:https://en.wikipedia.org/wiki/Invertible_matrix inversa] della matrice [page:Matrix4 m].
  156. </p>
  157. <h3>[method:this identity]()</h3>
  158. <p>
  159. Reimposta questa matrice alla matrice identità 3x3:
  160. </p>
  161. <math display="block">
  162. <mrow>
  163. <mo>[</mo>
  164. <mtable>
  165. <mtr>
  166. <mtd><mn>1</mn></mtd>
  167. <mtd><mn>0</mn></mtd>
  168. <mtd><mn>0</mn></mtd>
  169. </mtr>
  170. <mtr>
  171. <mtd><mn>0</mn></mtd>
  172. <mtd><mn>1</mn></mtd>
  173. <mtd><mn>0</mn></mtd>
  174. </mtr>
  175. <mtr>
  176. <mtd><mn>0</mn></mtd>
  177. <mtd><mn>0</mn></mtd>
  178. <mtd><mn>1</mn></mtd>
  179. </mtr>
  180. </mtable>
  181. <mo>]</mo>
  182. </mrow>
  183. </math>
  184. <h3>[method:this makeRotation]( [param:Float theta] )</h3>
  185. <p>
  186. [page:Float theta] — Angolo di rotazione in radianti. I valori positivi ruotano in senso antiorario.<br /><br />
  187. Imposta questa matrice come una trasformazione rotazionale 2D di [page:Float teta] radianti.
  188. La matrice risultante sarà:
  189. </p>
  190. <math display="block">
  191. <mrow>
  192. <mo>[</mo>
  193. <mtable>
  194. <mtr>
  195. <mtd>
  196. <mi>cos</mi>
  197. <mi>&theta;</mi>
  198. </mtd>
  199. <mtd>
  200. <mi>-sin</mi>
  201. <mi>&theta;</mi>
  202. </mtd>
  203. <mtd>
  204. <mn>0</mn>
  205. </mtd>
  206. </mtr>
  207. <mtr>
  208. <mtd>
  209. <mi>sin</mi>
  210. <mi>&theta;</mi>
  211. </mtd>
  212. <mtd>
  213. <mi>cos</mi>
  214. <mi>&theta;</mi>
  215. </mtd>
  216. <mtd>
  217. <mn>0</mn>
  218. </mtd>
  219. </mtr>
  220. <mtr>
  221. <mtd><mn>0</mn></mtd>
  222. <mtd><mn>0</mn></mtd>
  223. <mtd><mn>1</mn></mtd>
  224. </mtr>
  225. </mtable>
  226. <mo>]</mo>
  227. </mrow>
  228. </math>
  229. <h3>[method:this makeScale]( [param:Float x], [param:Float y] )</h3>
  230. <p>
  231. [page:Float x] - la quantità da scalare sull'asse X.<br />
  232. [page:Float y] - la quantità da scalare sull'asse Y.<br />
  233. Imposta questa matrice come una trasformazione di scala 2D:
  234. </p>
  235. <math display="block">
  236. <mrow>
  237. <mo>[</mo>
  238. <mtable>
  239. <mtr>
  240. <mtd><mi>x</mi></mtd>
  241. <mtd><mn>0</mn></mtd>
  242. <mtd><mn>0</mn></mtd>
  243. </mtr>
  244. <mtr>
  245. <mtd><mn>0</mn></mtd>
  246. <mtd><mi>y</mi></mtd>
  247. <mtd><mn>0</mn></mtd>
  248. </mtr>
  249. <mtr>
  250. <mtd><mn>0</mn></mtd>
  251. <mtd><mn>0</mn></mtd>
  252. <mtd><mn>1</mn></mtd>
  253. </mtr>
  254. </mtable>
  255. <mo>]</mo>
  256. </mrow>
  257. </math>
  258. <h3>[method:this makeTranslation]( [param:Vector2 v] )</h3>
  259. <h3>[method:this makeTranslation]( [param:Float x], [param:Float y] )</h3>
  260. <p>
  261. [page:Vector2 v] a translation transform from vector.<br />
  262. or<br />
  263. [page:Float x] - la quantità da translare sull'asse X.<br />
  264. [page:Float y] - la quantità da translare sull'asse Y.<br />
  265. Imposta questa matrice come una trasformazione di traslazione 2D:
  266. </p>
  267. <math display="block">
  268. <mrow>
  269. <mo>[</mo>
  270. <mtable>
  271. <mtr>
  272. <mtd><mn>1</mn></mtd>
  273. <mtd><mn>0</mn></mtd>
  274. <mtd><mi>x</mi></mtd>
  275. </mtr>
  276. <mtr>
  277. <mtd><mn>0</mn></mtd>
  278. <mtd><mn>1</mn></mtd>
  279. <mtd><mi>y</mi></mtd>
  280. </mtr>
  281. <mtr>
  282. <mtd><mn>0</mn></mtd>
  283. <mtd><mn>0</mn></mtd>
  284. <mtd><mn>1</mn></mtd>
  285. </mtr>
  286. </mtable>
  287. <mo>]</mo>
  288. </mrow>
  289. </math>
  290. <h3>[method:this multiply]( [param:Matrix3 m] )</h3>
  291. <p>Post-moltiplica questa matrice per [page:Matrix3 m].</p>
  292. <h3>[method:this multiplyMatrices]( [param:Matrix3 a], [param:Matrix3 b] )</h3>
  293. <p>Imposta questa matrice ad [page:Matrix3 a] x [page:Matrix3 b].</p>
  294. <h3>[method:this multiplyScalar]( [param:Float s] )</h3>
  295. <p>Moltiplica ogni componente della matrice per il valore scalare *s*.</p>
  296. <h3>[method:this rotate]( [param:Float theta] )</h3>
  297. <p>Ruota questa matrice dell'angolo dato (in radianti).</p>
  298. <h3>[method:this scale]( [param:Float sx], [param:Float sy] )</h3>
  299. <p>Ridimensiona questa matrice dei valori scalari passati.</p>
  300. <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>
  301. <p>
  302. Imposta i valori della matrice 3x3 sulla sequenza di valori della
  303. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major] specificata.
  304. </p>
  305. <math display="block">
  306. <mrow>
  307. <mo>[</mo>
  308. <mtable>
  309. <mtr>
  310. <mtd><mi>n11</mi></mtd>
  311. <mtd><mi>n12</mi></mtd>
  312. <mtd><mi>n13</mi></mtd>
  313. </mtr>
  314. <mtr>
  315. <mtd><mi>n21</mi></mtd>
  316. <mtd><mi>n22</mi></mtd>
  317. <mtd><mi>n23</mi></mtd>
  318. </mtr>
  319. <mtr>
  320. <mtd><mi>n31</mi></mtd>
  321. <mtd><mi>n32</mi></mtd>
  322. <mtd><mi>n33</mi></mtd>
  323. </mtr>
  324. </mtable>
  325. <mo>]</mo>
  326. </mrow>
  327. </math>
  328. <h3>[method:this premultiply]( [param:Matrix3 m] )</h3>
  329. <p>Pre-moltiplica questa matrice per [page:Matrix3 m].</p>
  330. <h3>[method:this setFromMatrix4]( [param:Matrix4 m] )</h3>
  331. <p>Imposta questa matrice sulla matrice 3x3 superiore di Matrix4 [page:Matrix4 m].</p>
  332. <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>
  333. <p>
  334. [page:Float tx] - offset x<br />
  335. [page:Float ty] - offset y<br />
  336. [page:Float sx] - repeat x<br />
  337. [page:Float sy] - repeat y<br />
  338. [page:Float rotation] - rotazione, in radianti. I valori positivi ruotano in senso antiorario<br />
  339. [page:Float cx] - centro x di rotazione<br />
  340. [page:Float cy] - centro y di rotazione<br /><br />
  341. Imposta la matrice di trasformazione UV da offset, ripetizione, rotazione e centro.
  342. </p>
  343. <h3>[method:Array toArray]( [param:Array array], [param:Integer offset] )</h3>
  344. <p>
  345. [page:Array array] - (opzionale) array per memorizzare il vettore risultante. In caso contrario, verrà creato un nuovo array.<br />
  346. [page:Integer offset] - (opzionale) offset nell'array in cui inserire il risultato.<br /><br />
  347. Scrive gli elementi di questa matrice in una matrice in formato
  348. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major].
  349. </p>
  350. <h3>[method:this translate]( [param:Float tx], [param:Float ty] )</h3>
  351. <p>Trasla questa matrice dei valori scalari dati.</p>
  352. <h3>[method:this transpose]()</h3>
  353. <p>[link:https://en.wikipedia.org/wiki/Transpose Traspone] questa matrice al suo posto.</p>
  354. <h3>[method:this transposeIntoArray]( [param:Array array] )</h3>
  355. <p>
  356. [page:Array array] - array per memorizzare il vettore risultante.<br /><br />
  357. [link:https://en.wikipedia.org/wiki/Transpose Traspone] questa matrice nell'array fornito,
  358. e ritorna immutato.
  359. </p>
  360. <h2>Source</h2>
  361. <p>
  362. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  363. </p>
  364. </body>
  365. </html>