Matrix4.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  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 4x4
  13. [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].<br /><br />
  14. The most common use of a 4x4 matrix in 3D computer graphics is as a
  15. [link:https://en.wikipedia.org/wiki/Transformation_matrix Transformation Matrix].
  16. For an introduction to transformation matrices as used in WebGL,
  17. check out
  18. [link:http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices this tutorial].<br /><br />
  19. This allows a [page:Vector3] representing a point in 3D space to undergo
  20. transformations such as translation, rotation, shear, scale, reflection,
  21. orthogonal or perspective projection and so on, by being multiplied by the
  22. matrix. This is known as `applying` the matrix to the vector.<br /><br />
  23. Every [page:Object3D] has three associated Matrix4s:
  24. </p>
  25. <ul>
  26. <li>
  27. [page:Object3D.matrix]: This stores the local transform of the object.
  28. This is the object's transformation relative to its parent.
  29. </li>
  30. <li>
  31. [page:Object3D.matrixWorld]: The global or world transform of the
  32. object. If the object has no parent, then this is identical to the local
  33. transform stored in [page:Object3D.matrix matrix].
  34. </li>
  35. <li>
  36. [page:Object3D.modelViewMatrix]: This represents the object's
  37. transformation relative to the camera's coordinate system. An object's
  38. modelViewMatrix is the object's matrixWorld pre-multiplied by the
  39. camera's matrixWorldInverse.
  40. </li>
  41. </ul>
  42. [page:Camera Cameras] have three additional Matrix4s:
  43. <ul>
  44. <li>
  45. [page:Camera.matrixWorldInverse]: The view matrix - the inverse of the
  46. Camera's [page:Object3D.matrixWorld matrixWorld].
  47. </li>
  48. <li>
  49. [page:Camera.projectionMatrix]: Represents the information how to
  50. project the scene to clip space.
  51. </li>
  52. <li>
  53. [page:Camera.projectionMatrixInverse]: The inverse of projectionMatrix.
  54. </li>
  55. </ul>
  56. Note: [page:Object3D.normalMatrix] is not a Matrix4, but a [page:Matrix3].
  57. <h2>A Note on Row-Major and Column-Major Ordering</h2>
  58. <p>
  59. The constructor and [page:.set set]() method take arguments in
  60. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major]
  61. order, while internally they are stored in the [page:.elements elements] array in column-major order.<br /><br />
  62. This means that calling
  63. <code>
  64. const m = new THREE.Matrix4();
  65. m.set( 11, 12, 13, 14,
  66. 21, 22, 23, 24,
  67. 31, 32, 33, 34,
  68. 41, 42, 43, 44 );
  69. </code>
  70. will result in the [page:.elements elements] array containing:
  71. <code>
  72. m.elements = [ 11, 21, 31, 41,
  73. 12, 22, 32, 42,
  74. 13, 23, 33, 43,
  75. 14, 24, 34, 44 ];
  76. </code>
  77. and internally all calculations are performed using column-major ordering.
  78. However, as the actual ordering makes no difference mathematically and
  79. most people are used to thinking about matrices in row-major order, the
  80. three.js documentation shows matrices in row-major order. Just bear in
  81. mind that if you are reading the source code, you'll have to take the
  82. [link:https://en.wikipedia.org/wiki/Transpose transpose] of any matrices
  83. outlined here to make sense of the calculations.
  84. </p>
  85. <h2>Extracting position, rotation and scale</h2>
  86. <p>
  87. There are several options available for extracting position, rotation and
  88. scale from a Matrix4.
  89. </p>
  90. <ul>
  91. <li>
  92. [page:Vector3.setFromMatrixPosition]: can be used to extract the
  93. translation component.
  94. </li>
  95. <li>
  96. [page:Vector3.setFromMatrixScale]: can be used to extract the scale
  97. component.
  98. </li>
  99. <li>
  100. [page:Quaternion.setFromRotationMatrix],
  101. [page:Euler.setFromRotationMatrix] or [page:.extractRotation extractRotation]
  102. can be used to extract the rotation component from a pure (unscaled) matrix.
  103. </li>
  104. <li>
  105. [page:.decompose decompose] can be used to extract position, rotation
  106. and scale all at once.
  107. </li>
  108. </ul>
  109. <h2>Constructor</h2>
  110. <h3>[name]( [param:Number n11], [param:Number n12], [param:Number n13], [param:Number n14],
  111. [param:Number n21], [param:Number n22], [param:Number n23], [param:Number n24],
  112. [param:Number n31], [param:Number n32], [param:Number n33], [param:Number n34],
  113. [param:Number n41], [param:Number n42], [param:Number n43], [param:Number n44] )</h3>
  114. <p>
  115. Creates a 4x4 matrix with the given arguments in row-major order. If no arguments are provided, the constructor initializes
  116. the [name] to the 4x4 [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
  117. </p>
  118. <h2>Properties</h2>
  119. <h3>[property:Array elements]</h3>
  120. <p>
  121. A
  122. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] list of matrix values.
  123. </p>
  124. <h2>Methods</h2>
  125. <h3>[method:Matrix4 clone]()</h3>
  126. <p>
  127. Creates a new Matrix4 with identical [page:.elements elements] to this
  128. one.
  129. </p>
  130. <h3>
  131. [method:this compose]( [param:Vector3 position], [param:Quaternion quaternion], [param:Vector3 scale] )
  132. </h3>
  133. <p>
  134. Sets this matrix to the transformation composed of [page:Vector3 position],
  135. [page:Quaternion quaternion] and [page:Vector3 scale].
  136. </p>
  137. <h3>[method:this copy]( [param:Matrix4 m] )</h3>
  138. <p>
  139. Copies the [page:.elements elements] of matrix [page:Matrix4 m] into this
  140. matrix.
  141. </p>
  142. <h3>[method:this copyPosition]( [param:Matrix4 m] )</h3>
  143. <p>
  144. Copies the translation component of the supplied matrix [page:Matrix4 m]
  145. into this matrix's translation component.
  146. </p>
  147. <h3>
  148. [method:this decompose]( [param:Vector3 position], [param:Quaternion quaternion], [param:Vector3 scale] )
  149. </h3>
  150. <p>
  151. Decomposes this matrix into its [page:Vector3 position], [page:Quaternion quaternion]
  152. and [page:Vector3 scale] components.<br /><br />
  153. Note: Not all matrices are decomposable in this way. For example, if an
  154. object has a non-uniformly scaled parent, then the object's world matrix
  155. may not be decomposable, and this method may not be appropriate.
  156. </p>
  157. <h3>[method:Float determinant]()</h3>
  158. <p>
  159. Computes and returns the [link:https://en.wikipedia.org/wiki/Determinant determinant] of this matrix.<br /><br />
  160. Based on the method outlined
  161. [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html here].
  162. </p>
  163. <h3>[method:Boolean equals]( [param:Matrix4 m] )</h3>
  164. <p>Return true if this matrix and [page:Matrix4 m] are equal.</p>
  165. <h3>
  166. [method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )
  167. </h3>
  168. <p>
  169. Extracts the [link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis]
  170. of this matrix into the three axis vectors provided. If this matrix
  171. is:
  172. </p>
  173. <math display="block">
  174. <mrow>
  175. <mo>[</mo>
  176. <mtable>
  177. <mtr>
  178. <mtd><mi>a</mi></mtd>
  179. <mtd><mi>b</mi></mtd>
  180. <mtd><mi>c</mi></mtd>
  181. <mtd><mi>d</mi></mtd>
  182. </mtr>
  183. <mtr>
  184. <mtd><mi>e</mi></mtd>
  185. <mtd><mi>f</mi></mtd>
  186. <mtd><mi>g</mi></mtd>
  187. <mtd><mi>h</mi></mtd>
  188. </mtr>
  189. <mtr>
  190. <mtd><mi>i</mi></mtd>
  191. <mtd><mi>j</mi></mtd>
  192. <mtd><mi>k</mi></mtd>
  193. <mtd><mi>l</mi></mtd>
  194. </mtr>
  195. <mtr>
  196. <mtd><mi>m</mi></mtd>
  197. <mtd><mi>n</mi></mtd>
  198. <mtd><mi>o</mi></mtd>
  199. <mtd><mi>p</mi></mtd>
  200. </mtr>
  201. </mtable>
  202. <mo>]</mo>
  203. </mrow>
  204. </math>
  205. <p>
  206. then the [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis]
  207. will be set to:
  208. </p>
  209. <div style="text-align: center">
  210. <math>
  211. <mrow>
  212. <mi>xAxis</mi>
  213. <mo>=</mo>
  214. <mo>[</mo>
  215. <mtable>
  216. <mtr><mtd style="height: 1rem"><mi>a</mi></mtd></mtr>
  217. <mtr><mtd style="height: 1rem"><mi>e</mi></mtd></mtr>
  218. <mtr><mtd style="height: 1rem"><mi>i</mi></mtd></mtr>
  219. </mtable>
  220. <mo>]</mo>
  221. </mrow>
  222. </math>,
  223. <math>
  224. <mrow>
  225. <mi>yAxis</mi>
  226. <mo>=</mo>
  227. <mo>[</mo>
  228. <mtable>
  229. <mtr><mtd style="height: 1rem"><mi>b</mi></mtd></mtr>
  230. <mtr><mtd style="height: 1rem"><mi>f</mi></mtd></mtr>
  231. <mtr><mtd style="height: 1rem"><mi>j</mi></mtd></mtr>
  232. </mtable>
  233. <mo>]</mo>
  234. </mrow>
  235. </math>, and
  236. <math>
  237. <mrow>
  238. <mi>zAxis</mi>
  239. <mo>=</mo>
  240. <mo>[</mo>
  241. <mtable>
  242. <mtr><mtd style="height: 1rem"><mi>c</mi></mtd></mtr>
  243. <mtr><mtd style="height: 1rem"><mi>g</mi></mtd></mtr>
  244. <mtr><mtd style="height: 1rem"><mi>k</mi></mtd></mtr>
  245. </mtable>
  246. <mo>]</mo>
  247. </mrow>
  248. </math>
  249. </div>
  250. <h3>[method:this extractRotation]( [param:Matrix4 m] )</h3>
  251. <p>
  252. Extracts the rotation component of the supplied matrix [page:Matrix4 m]
  253. into this matrix's rotation component.
  254. </p>
  255. <h3>
  256. [method:this fromArray]( [param:Array array], [param:Integer offset] )
  257. </h3>
  258. <p>
  259. [page:Array array] - the array to read the elements from.<br />
  260. [page:Integer offset] - ( optional ) offset into the array. Default is
  261. 0.<br /><br />
  262. Sets the elements of this matrix based on an [page:Array array] in
  263. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  264. </p>
  265. <h3>[method:this invert]()</h3>
  266. <p>
  267. Inverts this matrix, using the
  268. [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method].
  269. You can not invert with a determinant of zero. If you
  270. attempt this, the method produces a zero matrix instead.
  271. </p>
  272. <h3>[method:Float getMaxScaleOnAxis]()</h3>
  273. <p>Gets the maximum scale value of the 3 axes.</p>
  274. <h3>[method:this identity]()</h3>
  275. <p>
  276. Resets this matrix to the
  277. [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
  278. </p>
  279. <h3>
  280. [method:this lookAt]( [param:Vector3 eye], [param:Vector3 target], [param:Vector3 up] )
  281. </h3>
  282. <p>
  283. Constructs a rotation matrix, looking from [page:Vector3 eye] towards
  284. [page:Vector3 target] oriented by the [page:Vector3 up] vector.
  285. </p>
  286. <h3>
  287. [method:this makeRotationAxis]( [param:Vector3 axis], [param:Float theta] )
  288. </h3>
  289. <p>
  290. [page:Vector3 axis] — Rotation axis, should be normalized.<br />
  291. [page:Float theta] — Rotation angle in radians.<br /><br />
  292. Sets this matrix as rotation transform around [page:Vector3 axis] by
  293. [page:Float theta] radians.<br />
  294. This is a somewhat controversial but mathematically sound alternative to
  295. rotating via [page:Quaternion Quaternions]. See the discussion
  296. [link:https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199 here].
  297. </p>
  298. <h3>
  299. [method:this makeBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )
  300. </h3>
  301. <p>
  302. Set this to the [link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis]
  303. matrix consisting of the three provided basis vectors:
  304. </p>
  305. <math display="block">
  306. <mrow>
  307. <mo>[</mo>
  308. <mtable>
  309. <mtr>
  310. <mtd><mi>xAxis.x</mi></mtd>
  311. <mtd><mi>yAxis.x</mi></mtd>
  312. <mtd><mi>zAxis.x</mi></mtd>
  313. <mtd><mn>0</mn></mtd>
  314. </mtr>
  315. <mtr>
  316. <mtd><mi>xAxis.y</mi></mtd>
  317. <mtd><mi>yAxis.y</mi></mtd>
  318. <mtd><mi>zAxis.y</mi></mtd>
  319. <mtd><mn>0</mn></mtd>
  320. </mtr>
  321. <mtr>
  322. <mtd><mi>xAxis.z</mi></mtd>
  323. <mtd><mi>yAxis.z</mi></mtd>
  324. <mtd><mi>zAxis.z</mi></mtd>
  325. <mtd><mn>0</mn></mtd>
  326. </mtr>
  327. <mtr>
  328. <mtd><mn>0</mn></mtd>
  329. <mtd><mn>0</mn></mtd>
  330. <mtd><mn>0</mn></mtd>
  331. <mtd><mn>1</mn></mtd>
  332. </mtr>
  333. </mtable>
  334. <mo>]</mo>
  335. </mrow>
  336. </math>
  337. <h3>
  338. [method:this makePerspective]( [param:Float left], [param:Float right], [param:Float top], [param:Float bottom], [param:Float near], [param:Float far] )
  339. </h3>
  340. <p>
  341. Creates a
  342. [link:https://en.wikipedia.org/wiki/3D_projection#Perspective_projection perspective projection]
  343. matrix. This is used internally by
  344. [page:PerspectiveCamera.updateProjectionMatrix]()
  345. </p>
  346. <h3>
  347. [method:this makeOrthographic]( [param:Float left], [param:Float right], [param:Float top], [param:Float bottom], [param:Float near], [param:Float far] )
  348. </h3>
  349. <p>
  350. Creates an [link:https://en.wikipedia.org/wiki/Orthographic_projection orthographic projection]
  351. matrix. This is used internally by
  352. [page:OrthographicCamera.updateProjectionMatrix]().
  353. </p>
  354. <h3>[method:this makeRotationFromEuler]( [param:Euler euler] )</h3>
  355. <p>
  356. Sets the rotation component (the upper left 3x3 matrix) of this matrix to
  357. the rotation specified by the given [page:Euler Euler Angle]. The rest of
  358. the matrix is set to the identity. Depending on the [page:Euler.order order]
  359. of the [page:Euler euler], there are six possible outcomes. See
  360. [link:https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix this page] for a complete list.
  361. </p>
  362. <h3>[method:this makeRotationFromQuaternion]( [param:Quaternion q] )</h3>
  363. <p>
  364. Sets the rotation component of this matrix to the rotation specified by
  365. [page:Quaternion q], as outlined
  366. [link:https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion here]. The
  367. rest of the matrix is set to the identity. So, given [page:Quaternion q] =
  368. w + xi + yj + zk, the resulting matrix will be:
  369. </p>
  370. <math display="block">
  371. <mrow>
  372. <mo>[</mo>
  373. <mtable>
  374. <mtr>
  375. <mtd>
  376. <mn>1</mn>
  377. <mo>-</mo>
  378. <mn>2</mn>
  379. <msup>
  380. <mi>y</mi>
  381. <mn>2</mn>
  382. </msup>
  383. <mo>-</mo>
  384. <mn>2</mn>
  385. <msup>
  386. <mi>z</mi>
  387. <mn>2</mn>
  388. </msup>
  389. </mtd>
  390. <mtd>
  391. <mn>2</mn>
  392. <mi>x</mi>
  393. <mi>y</mi>
  394. <mo>-</mo>
  395. <mn>2</mn>
  396. <mi>z</mi>
  397. <mi>w</mi>
  398. </mtd>
  399. <mtd>
  400. <mn>2</mn>
  401. <mi>x</mi>
  402. <mi>z</mi>
  403. <mo>+</mo>
  404. <mn>2</mn>
  405. <mi>y</mi>
  406. <mi>w</mi>
  407. </mtd>
  408. <mtd>
  409. <mn>0</mn>
  410. </mtd>
  411. </mtr>
  412. <mtr>
  413. <mtd>
  414. <mn>2</mn>
  415. <mi>x</mi>
  416. <mi>y</mi>
  417. <mo>+</mo>
  418. <mn>2</mn>
  419. <mi>z</mi>
  420. <mi>w</mi>
  421. </mtd>
  422. <mtd>
  423. <mn>1</mn>
  424. <mo>-</mo>
  425. <mn>2</mn>
  426. <msup>
  427. <mi>x</mi>
  428. <mn>2</mn>
  429. </msup>
  430. <mo>-</mo>
  431. <mn>2</mn>
  432. <msup>
  433. <mi>z</mi>
  434. <mn>2</mn>
  435. </msup>
  436. </mtd>
  437. <mtd>
  438. <mn>2</mn>
  439. <mi>y</mi>
  440. <mi>z</mi>
  441. <mo>-</mo>
  442. <mn>2</mn>
  443. <mi>x</mi>
  444. <mi>w</mi>
  445. </mtd>
  446. <mtd>
  447. <mn>0</mn>
  448. </mtd>
  449. </mtr>
  450. <mtr>
  451. <mtd>
  452. <mn>2</mn>
  453. <mi>x</mi>
  454. <mi>z</mi>
  455. <mo>-</mo>
  456. <mn>2</mn>
  457. <mi>y</mi>
  458. <mi>w</mi>
  459. </mtd>
  460. <mtd>
  461. <mn>2</mn>
  462. <mi>y</mi>
  463. <mi>z</mi>
  464. <mo>+</mo>
  465. <mn>2</mn>
  466. <mi>x</mi>
  467. <mi>w</mi>
  468. </mtd>
  469. <mtd>
  470. <mn>1</mn>
  471. <mo>-</mo>
  472. <mn>2</mn>
  473. <msup>
  474. <mi>x</mi>
  475. <mn>2</mn>
  476. </msup>
  477. <mo>-</mo>
  478. <mn>2</mn>
  479. <msup>
  480. <mi>y</mi>
  481. <mn>2</mn>
  482. </msup>
  483. </mtd>
  484. <mtd>
  485. <mn>0</mn>
  486. </mtd>
  487. </mtr>
  488. <mtr>
  489. <mtd><mn>0</mn></mtd>
  490. <mtd><mn>0</mn></mtd>
  491. <mtd><mn>0</mn></mtd>
  492. <mtd><mn>1</mn></mtd>
  493. </mtr>
  494. </mtable>
  495. <mo>]</mo>
  496. </mrow>
  497. </math>
  498. <h3>[method:this makeRotationX]( [param:Float theta] )</h3>
  499. <p>
  500. [page:Float theta] — Rotation angle in radians.<br /><br />
  501. Sets this matrix as a rotational transformation around the X axis by
  502. [page:Float theta] (&theta;) radians. The resulting matrix will be:
  503. </p>
  504. <math display="block">
  505. <mrow>
  506. <mo>[</mo>
  507. <mtable>
  508. <mtr>
  509. <mtd><mn>1</mn></mtd>
  510. <mtd><mn>0</mn></mtd>
  511. <mtd><mn>0</mn></mtd>
  512. <mtd><mn>0</mn></mtd>
  513. </mtr>
  514. <mtr>
  515. <mtd>
  516. <mn>0</mn>
  517. </mtd>
  518. <mtd>
  519. <mi>cos</mi>
  520. <mi>&theta;</mi>
  521. </mtd>
  522. <mtd>
  523. <mo>-</mo>
  524. <mi>sin</mi>
  525. <mi>&theta;</mi>
  526. </mtd>
  527. <mtd>
  528. <mn>0</mn>
  529. </mtd>
  530. </mtr>
  531. <mtr>
  532. <mtd>
  533. <mn>0</mn>
  534. </mtd>
  535. <mtd>
  536. <mi>sin</mi>
  537. <mi>&theta;</mi>
  538. </mtd>
  539. <mtd>
  540. <mi>cos</mi>
  541. <mi>&theta;</mi>
  542. </mtd>
  543. <mtd>
  544. <mn>0</mn>
  545. </mtd>
  546. </mtr>
  547. <mtr>
  548. <mtd><mn>0</mn></mtd>
  549. <mtd><mn>0</mn></mtd>
  550. <mtd><mn>0</mn></mtd>
  551. <mtd><mn>1</mn></mtd>
  552. </mtr>
  553. </mtable>
  554. <mo>]</mo>
  555. </mrow>
  556. </math>
  557. <h3>[method:this makeRotationY]( [param:Float theta] )</h3>
  558. <p>
  559. [page:Float theta] — Rotation angle in radians.<br /><br />
  560. Sets this matrix as a rotational transformation around the Y axis by
  561. [page:Float theta] (&theta;) radians. The resulting matrix will be:
  562. </p>
  563. <math display="block">
  564. <mrow>
  565. <mo>[</mo>
  566. <mtable>
  567. <mtr>
  568. <mtd>
  569. <mi>cos</mi>
  570. <mi>&theta;</mi>
  571. </mtd>
  572. <mtd>
  573. <mn>0</mn>
  574. </mtd>
  575. <mtd>
  576. <mi>sin</mi>
  577. <mi>&theta;</mi>
  578. </mtd>
  579. <mtd>
  580. <mn>0</mn>
  581. </mtd>
  582. </mtr>
  583. <mtr>
  584. <mtd><mn>0</mn></mtd>
  585. <mtd><mn>1</mn></mtd>
  586. <mtd><mn>0</mn></mtd>
  587. <mtd><mn>0</mn></mtd>
  588. </mtr>
  589. <mtr>
  590. <mtd>
  591. <mo>-</mo>
  592. <mi>sin</mi>
  593. <mi>&theta;</mi>
  594. </mtd>
  595. <mtd>
  596. <mn>0</mn>
  597. </mtd>
  598. <mtd>
  599. <mi>cos</mi>
  600. <mi>&theta;</mi>
  601. </mtd>
  602. <mtd>
  603. <mn>0</mn>
  604. </mtd>
  605. </mtr>
  606. <mtr>
  607. <mtd><mn>0</mn></mtd>
  608. <mtd><mn>0</mn></mtd>
  609. <mtd><mn>0</mn></mtd>
  610. <mtd><mn>1</mn></mtd>
  611. </mtr>
  612. </mtable>
  613. <mo>]</mo>
  614. </mrow>
  615. </math>
  616. <h3>[method:this makeRotationZ]( [param:Float theta] )</h3>
  617. <p>
  618. [page:Float theta] — Rotation angle in radians.<br /><br />
  619. Sets this matrix as a rotational transformation around the Z axis by
  620. [page:Float theta] (&theta;) radians. The resulting matrix will be:
  621. </p>
  622. <math display="block">
  623. <mrow>
  624. <mo>[</mo>
  625. <mtable>
  626. <mtr>
  627. <mtd>
  628. <mi>cos</mi>
  629. <mi>&theta;</mi>
  630. </mtd>
  631. <mtd>
  632. <mo>-</mo>
  633. <mi>sin</mi>
  634. <mi>&theta;</mi>
  635. </mtd>
  636. <mtd>
  637. <mn>0</mn>
  638. </mtd>
  639. <mtd>
  640. <mn>0</mn>
  641. </mtd>
  642. </mtr>
  643. <mtr>
  644. <mtd>
  645. <mi>sin</mi>
  646. <mi>&theta;</mi>
  647. </mtd>
  648. <mtd>
  649. <mi>cos</mi>
  650. <mi>&theta;</mi>
  651. </mtd>
  652. <mtd>
  653. <mn>0</mn>
  654. </mtd>
  655. <mtd>
  656. <mn>0</mn>
  657. </mtd>
  658. </mtr>
  659. <mtr>
  660. <mtd><mn>0</mn></mtd>
  661. <mtd><mn>0</mn></mtd>
  662. <mtd><mn>1</mn></mtd>
  663. <mtd><mn>0</mn></mtd>
  664. </mtr>
  665. <mtr>
  666. <mtd><mn>0</mn></mtd>
  667. <mtd><mn>0</mn></mtd>
  668. <mtd><mn>0</mn></mtd>
  669. <mtd><mn>1</mn></mtd>
  670. </mtr>
  671. </mtable>
  672. <mo>]</mo>
  673. </mrow>
  674. </math>
  675. <h3>
  676. [method:this makeScale]( [param:Float x], [param:Float y], [param:Float z] )
  677. </h3>
  678. <p>
  679. [page:Float x] - the amount to scale in the X axis.<br />
  680. [page:Float y] - the amount to scale in the Y axis.<br />
  681. [page:Float z] - the amount to scale in the Z axis.<br /><br />
  682. Sets this matrix as scale transform:
  683. </p>
  684. <math display="block">
  685. <mrow>
  686. <mo>[</mo>
  687. <mtable>
  688. <mtr>
  689. <mtd><mi>x</mi></mtd>
  690. <mtd><mn>0</mn></mtd>
  691. <mtd><mn>0</mn></mtd>
  692. <mtd><mn>0</mn></mtd>
  693. </mtr>
  694. <mtr>
  695. <mtd><mn>0</mn></mtd>
  696. <mtd><mi>y</mi></mtd>
  697. <mtd><mn>0</mn></mtd>
  698. <mtd><mn>0</mn></mtd>
  699. </mtr>
  700. <mtr>
  701. <mtd><mn>0</mn></mtd>
  702. <mtd><mn>0</mn></mtd>
  703. <mtd><mi>z</mi></mtd>
  704. <mtd><mn>0</mn></mtd>
  705. </mtr>
  706. <mtr>
  707. <mtd><mn>0</mn></mtd>
  708. <mtd><mn>0</mn></mtd>
  709. <mtd><mn>0</mn></mtd>
  710. <mtd><mn>1</mn></mtd>
  711. </mtr>
  712. </mtable>
  713. <mo>]</mo>
  714. </mrow>
  715. </math>
  716. <h3>
  717. [method:this makeShear]( [param:Float xy], [param:Float xz], [param:Float yx],
  718. [param:Float yz], [param:Float zx], [param:Float zy] )
  719. </h3>
  720. <p>
  721. [page:Float xy] - the amount to shear X by Y.<br />
  722. [page:Float xz] - the amount to shear X by Z.<br />
  723. [page:Float yx] - the amount to shear Y by X.<br />
  724. [page:Float yz] - the amount to shear Y by Z.<br />
  725. [page:Float zx] - the amount to shear Z by X.<br />
  726. [page:Float zy] - the amount to shear Z by Y.<br /><br />
  727. Sets this matrix as a shear transform:
  728. </p>
  729. <math display="block">
  730. <mrow>
  731. <mo>[</mo>
  732. <mtable>
  733. <mtr>
  734. <mtd><mn>1</mn></mtd>
  735. <mtd><mi>y</mi><mi>x</mi></mtd>
  736. <mtd><mi>z</mi><mi>x</mi></mtd>
  737. <mtd><mn>0</mn></mtd>
  738. </mtr>
  739. <mtr>
  740. <mtd><mi>x</mi><mi>y</mi></mtd>
  741. <mtd><mn>1</mn></mtd>
  742. <mtd><mi>z</mi><mi>y</mi></mtd>
  743. <mtd><mn>0</mn></mtd>
  744. </mtr>
  745. <mtr>
  746. <mtd><mi>x</mi><mi>z</mi></mtd>
  747. <mtd><mi>y</mi><mi>z</mi></mtd>
  748. <mtd><mn>1</mn></mtd>
  749. <mtd><mn>0</mn></mtd>
  750. </mtr>
  751. <mtr>
  752. <mtd><mn>0</mn></mtd>
  753. <mtd><mn>0</mn></mtd>
  754. <mtd><mn>0</mn></mtd>
  755. <mtd><mn>1</mn></mtd>
  756. </mtr>
  757. </mtable>
  758. <mo>]</mo>
  759. </mrow>
  760. </math>
  761. <h3>[method:this makeTranslation]( [param:Vector3 v] )</h3>
  762. <h3>
  763. [method:this makeTranslation]( [param:Float x], [param:Float y], [param:Float z] ) // optional API
  764. </h3>
  765. <p>
  766. Sets this matrix as a translation transform from vector [page:Vector3 v], or numbers [page:Float x], [page:Float y] and [page:Float z]:
  767. </p>
  768. <math display="block">
  769. <mrow>
  770. <mo>[</mo>
  771. <mtable>
  772. <mtr>
  773. <mtd><mn>1</mn></mtd>
  774. <mtd><mn>0</mn></mtd>
  775. <mtd><mn>0</mn></mtd>
  776. <mtd><mi>x</mi></mtd>
  777. </mtr>
  778. <mtr>
  779. <mtd><mn>0</mn></mtd>
  780. <mtd><mn>1</mn></mtd>
  781. <mtd><mn>0</mn></mtd>
  782. <mtd><mi>y</mi></mtd>
  783. </mtr>
  784. <mtr>
  785. <mtd><mn>0</mn></mtd>
  786. <mtd><mn>0</mn></mtd>
  787. <mtd><mn>1</mn></mtd>
  788. <mtd><mi>z</mi></mtd>
  789. </mtr>
  790. <mtr>
  791. <mtd><mn>0</mn></mtd>
  792. <mtd><mn>0</mn></mtd>
  793. <mtd><mn>0</mn></mtd>
  794. <mtd><mn>1</mn></mtd>
  795. </mtr>
  796. </mtable>
  797. <mo>]</mo>
  798. </mrow>
  799. </math>
  800. <h3>[method:this multiply]( [param:Matrix4 m] )</h3>
  801. <p>Post-multiplies this matrix by [page:Matrix4 m].</p>
  802. <h3>
  803. [method:this multiplyMatrices]( [param:Matrix4 a], [param:Matrix4 b] )
  804. </h3>
  805. <p>Sets this matrix to [page:Matrix4 a] x [page:Matrix4 b].</p>
  806. <h3>[method:this multiplyScalar]( [param:Float s] )</h3>
  807. <p>
  808. Multiplies every component of the matrix by a scalar value [page:Float s].
  809. </p>
  810. <h3>[method:this premultiply]( [param:Matrix4 m] )</h3>
  811. <p>Pre-multiplies this matrix by [page:Matrix4 m].</p>
  812. <h3>[method:this scale]( [param:Vector3 v] )</h3>
  813. <p>Multiplies the columns of this matrix by vector [page:Vector3 v].</p>
  814. <h3>
  815. [method:this set]( [param:Float n11], [param:Float n12], [param:Float n13], [param:Float n14], [param:Float n21], [param:Float n22], [param:Float n23], [param:Float n24], [param:Float n31], [param:Float n32], [param:Float n33], [param:Float n34], [param:Float n41], [param:Float n42], [param:Float n43], [param:Float n44] )
  816. </h3>
  817. <p>
  818. Set the [page:.elements elements] of this matrix to the supplied row-major
  819. values [page:Float n11], [page:Float n12], ... [page:Float n44].
  820. </p>
  821. <h3>[method:this setFromMatrix3]( [param:Matrix3 m] )</h3>
  822. <p>
  823. Set the upper 3x3 elements of this matrix to the values of the Matrix3
  824. [page:Matrix3 m].
  825. </p>
  826. <h3>[method:this setPosition]( [param:Vector3 v] )</h3>
  827. <h3>
  828. [method:this setPosition]( [param:Float x], [param:Float y], [param:Float z] ) // optional API
  829. </h3>
  830. <p>
  831. Sets the position component for this matrix from vector [page:Vector3 v],
  832. without affecting the rest of the matrix - i.e. if the matrix is
  833. currently:
  834. </p>
  835. <math display="block">
  836. <mrow>
  837. <mo>[</mo>
  838. <mtable>
  839. <mtr>
  840. <mtd><mi>a</mi></mtd>
  841. <mtd><mi>b</mi></mtd>
  842. <mtd><mi>c</mi></mtd>
  843. <mtd><mi>d</mi></mtd>
  844. </mtr>
  845. <mtr>
  846. <mtd><mi>e</mi></mtd>
  847. <mtd><mi>f</mi></mtd>
  848. <mtd><mi>g</mi></mtd>
  849. <mtd><mi>h</mi></mtd>
  850. </mtr>
  851. <mtr>
  852. <mtd><mi>i</mi></mtd>
  853. <mtd><mi>j</mi></mtd>
  854. <mtd><mi>k</mi></mtd>
  855. <mtd><mi>l</mi></mtd>
  856. </mtr>
  857. <mtr>
  858. <mtd><mi>m</mi></mtd>
  859. <mtd><mi>n</mi></mtd>
  860. <mtd><mi>o</mi></mtd>
  861. <mtd><mi>p</mi></mtd>
  862. </mtr>
  863. </mtable>
  864. <mo>]</mo>
  865. </mrow>
  866. </math>
  867. <p>This becomes:</p>
  868. <math display="block">
  869. <mrow>
  870. <mo>[</mo>
  871. <mtable>
  872. <mtr>
  873. <mtd><mi>a</mi></mtd>
  874. <mtd><mi>b</mi></mtd>
  875. <mtd><mi>c</mi></mtd>
  876. <mtd><mi>v.x</mi></mtd>
  877. </mtr>
  878. <mtr>
  879. <mtd><mi>e</mi></mtd>
  880. <mtd><mi>f</mi></mtd>
  881. <mtd><mi>g</mi></mtd>
  882. <mtd><mi>v.y</mi></mtd>
  883. </mtr>
  884. <mtr>
  885. <mtd><mi>i</mi></mtd>
  886. <mtd><mi>j</mi></mtd>
  887. <mtd><mi>k</mi></mtd>
  888. <mtd><mi>v.z</mi></mtd>
  889. </mtr>
  890. <mtr>
  891. <mtd><mi>m</mi></mtd>
  892. <mtd><mi>n</mi></mtd>
  893. <mtd><mi>o</mi></mtd>
  894. <mtd><mi>p</mi></mtd>
  895. </mtr>
  896. </mtable>
  897. <mo>]</mo>
  898. </mrow>
  899. </math>
  900. <h3>
  901. [method:Array toArray]( [param:Array array], [param:Integer offset] )
  902. </h3>
  903. <p>
  904. [page:Array array] - (optional) array to store the resulting vector in.<br />
  905. [page:Integer offset] - (optional) offset in the array at which to put the
  906. result.<br /><br />
  907. Writes the elements of this matrix to an array in
  908. [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
  909. </p>
  910. <h3>[method:this transpose]()</h3>
  911. <p>
  912. [link:https://en.wikipedia.org/wiki/Transpose Transposes] this matrix.
  913. </p>
  914. <h2>Source</h2>
  915. <p>
  916. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  917. </p>
  918. </body>
  919. </html>