2
0

Matrix4.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. <!DOCTYPE html>
  2. <html lang="zh">
  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. 表示为一个 4x4 [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].<br /><br />
  13. 在3D计算机图形学中,4x4矩阵最常用的用法是作为一个变换矩阵[link:https://en.wikipedia.org/wiki/Transformation_matrix Transformation Matrix]。
  14. 有关WebGL中使用的变换矩阵的介绍,请参阅本教程[link:http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices this tutorial]。<br /><br />
  15. 这使得表示三维空间中的一个点的向量[page:Vector3]通过乘以矩阵来进行转换,如平移、旋转、剪切、缩放、反射、正交或透视投影等。这就是把矩阵<em>应用</em>到向量上。<br /><br />
  16. 任何3D物体[page:Object3D]都有三个关联的矩阵:
  17. <ul>
  18. <li>
  19. [page:Object3D.matrix]: 存储物体的本地变换矩阵。 这是对象相对于其父对象的变换矩阵。
  20. </li>
  21. <li>
  22. [page:Object3D.matrixWorld]: 对象的全局或世界变换矩阵。如果对象没有父对象,那么这与存储在矩阵[page:Object3D.matrix matrix]中的本地变换矩阵相同。
  23. </li>
  24. <li>
  25. [page:Object3D.modelViewMatrix]: 表示对象相对于摄像机坐标系的变换矩阵,
  26. 一个对象的 modelViewMatrix 是物体世界变换矩阵乘以摄像机相对于世界空间变换矩阵的逆矩阵。
  27. </li>
  28. </ul>
  29. 摄像机[page:Camera Cameras] 有三个额外的四维矩阵:
  30. <ul>
  31. <li>
  32. [page:Camera.matrixWorldInverse]: 视矩阵 - 摄像机世界坐标变换的逆矩阵。
  33. </li>
  34. <li>
  35. [page:Camera.projectionMatrix]: 投影变换矩阵,表示将场景中的信息投影到裁剪空间。
  36. </li>
  37. <li>
  38. [page:Camera.projectionMatrixInverse]: 投影变换矩阵的逆矩阵。
  39. </li>
  40. </ul>
  41. 注意:物体的正规矩阵 [page:Object3D.normalMatrix] 并不是一个4维矩阵,而是一个三维矩阵[page:Matrix3]。
  42. </p>
  43. <h2>注意行优先列优先的顺序。</h2>
  44. <p>
  45. 设置[page:.set set]()方法参数采用行优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major],
  46. 而它们在内部是用列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]顺序存储在数组当中。<br /><br />
  47. 这意味着
  48. <code>
  49. const m = new THREE.Matrix4();
  50. m.set( 11, 12, 13, 14,
  51. 21, 22, 23, 24,
  52. 31, 32, 33, 34,
  53. 41, 42, 43, 44 );
  54. </code>
  55. 元素数组[page:.elements elements]将存储为:
  56. <code>
  57. m.elements = [ 11, 21, 31, 41,
  58. 12, 22, 32, 42,
  59. 13, 23, 33, 43,
  60. 14, 24, 34, 44 ];
  61. </code>
  62. 在内部,所有的计算都是使用列优先顺序进行的。然而,由于实际的排序在数学上没有什么不同,
  63. 而且大多数人习惯于以行优先顺序考虑矩阵,所以three.js文档以行为主的顺序显示矩阵。
  64. 请记住,如果您正在阅读源代码,您必须对这里列出的任何矩阵进行转置[link:https://en.wikipedia.org/wiki/Transpose transpose],以理解计算。
  65. </p>
  66. <h2>提取位置(平移)、旋转和缩放</h2>
  67. <p>
  68. 有多种选项可用于从 Matrix4 中提取位置、旋转和缩放。
  69. <ul>
  70. <li>
  71. [page:Vector3.setFromMatrixPosition]:可用于提取位置相关的分量。
  72. </li>
  73. <li>
  74. [page:Vector3.setFromMatrixScale]:可用于提取缩放相关的分量。
  75. </li>
  76. <li>
  77. [page:Quaternion.setFromRotationMatrix], [page:Euler.setFromRotationMatrix] 或 [page:.extractRotation extractRotation]:可用于从纯(未缩放)矩阵中提取旋转相关分量。
  78. </li>
  79. <li>
  80. [page:.decompose decompose]:可用于一次性提取位置、旋转和缩放
  81. </li>
  82. </ul>
  83. </p>
  84. <h2>构造器(Constructor)</h2>
  85. <h3>[name]( [param:Number n11], [param:Number n12], [param:Number n13], [param:Number n14],
  86. [param:Number n21], [param:Number n22], [param:Number n23], [param:Number n24],
  87. [param:Number n31], [param:Number n32], [param:Number n33], [param:Number n34],
  88. [param:Number n41], [param:Number n42], [param:Number n43], [param:Number n44] )</h3>
  89. <p>
  90. Creates a 4x4 matrix with the given arguments in row-major order. If no arguments are provided, the constructor initializes
  91. the [name] to the 4x4 [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
  92. </p>
  93. <h2>属性(Properties)</h2>
  94. <h3>[property:Array elements]</h3>
  95. <p>
  96. 矩阵列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]列表。
  97. </p>
  98. <h2>方法(Methods)</h2>
  99. <h3>[method:Matrix4 clone]()</h3>
  100. <p>创建一个新的矩阵,元素[page:.elements elements]与该矩阵相同。</p>
  101. <h3>[method:this compose]( [param:Vector3 position], [param:Quaternion quaternion], [param:Vector3 scale] )</h3>
  102. <p>
  103. 设置将该对象位置 [page:Vector3 position],四元数[page:Quaternion quaternion] 和 缩放[page:Vector3 scale] 组合变换的矩阵。
  104. </p>
  105. <h3>[method:this copy]( [param:Matrix4 m] )</h3>
  106. <p>将矩阵[page:Matrix3 m]的元素[page:.elements elements]复制到当前矩阵中。</p>
  107. <h3>[method:this copyPosition]( [param:Matrix4 m] )</h3>
  108. <p>
  109. 将给定矩阵 [param:Matrix4 m] 的平移分量拷贝到当前矩阵中。
  110. </p>
  111. <h3>[method:this decompose]( [param:Vector3 position], [param:Quaternion quaternion], [param:Vector3 scale] )</h3>
  112. <p>
  113. 将矩阵分解到给定的平移[page:Vector3 position] ,旋转 [page:Quaternion quaternion],缩放[page:Vector3 scale]分量中。<br/><br/>
  114. 注意:并非所有矩阵都可以通过这种方式分解。 例如,如果一个对象有一个非均匀缩放的父对象,那么该对象的世界矩阵可能是不可分解的,这种方法可能不合适。
  115. </p>
  116. <h3>[method:Float determinant]()</h3>
  117. <p>
  118. 计算并返回矩阵的行列式[link:https://en.wikipedia.org/wiki/Determinant determinant] 。<br /><br />
  119. 基于这个的方法概述[link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm here]。
  120. </p>
  121. <h3>[method:Boolean equals]( [param:Matrix4 m] )</h3>
  122. <p>如果矩阵[page:Matrix3 m] 与当前矩阵所有对应元素相同则返回true。</p>
  123. <h3>[method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )</h3>
  124. <p>
  125. 将矩阵的基向量[link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis]提取到指定的3个轴向量中。
  126. 如果矩阵如下:<br /><br />
  127. <math>
  128. <mrow>
  129. <mo>[</mo>
  130. <mtable>
  131. <mtr>
  132. <mtd><mi>a</mi></mtd>
  133. <mtd><mi>b</mi></mtd>
  134. <mtd><mi>c</mi></mtd>
  135. <mtd><mi>d</mi></mtd>
  136. </mtr>
  137. <mtr>
  138. <mtd><mi>e</mi></mtd>
  139. <mtd><mi>f</mi></mtd>
  140. <mtd><mi>g</mi></mtd>
  141. <mtd><mi>h</mi></mtd>
  142. </mtr>
  143. <mtr>
  144. <mtd><mi>i</mi></mtd>
  145. <mtd><mi>j</mi></mtd>
  146. <mtd><mi>k</mi></mtd>
  147. <mtd><mi>l</mi></mtd>
  148. </mtr>
  149. <mtr>
  150. <mtd><mi>m</mi></mtd>
  151. <mtd><mi>n</mi></mtd>
  152. <mtd><mi>o</mi></mtd>
  153. <mtd><mi>p</mi></mtd>
  154. </mtr>
  155. </mtable>
  156. <mo>]</mo>
  157. </mrow>
  158. </math><br /><br />
  159. 然后x轴y轴z轴被设为:<br /><br />
  160. <math>
  161. <mrow>
  162. <mi>xAxis</mi>
  163. <mo>=</mo>
  164. <mo>[</mo>
  165. <mtable>
  166. <mtr><mtd style="height: 1rem"><mi>a</mi></mtd></mtr>
  167. <mtr><mtd style="height: 1rem"><mi>e</mi></mtd></mtr>
  168. <mtr><mtd style="height: 1rem"><mi>i</mi></mtd></mtr>
  169. </mtable>
  170. <mo>]</mo>
  171. </mrow>
  172. </math>,
  173. <math>
  174. <mrow>
  175. <mi>yAxis</mi>
  176. <mo>=</mo>
  177. <mo>[</mo>
  178. <mtable>
  179. <mtr><mtd style="height: 1rem"><mi>b</mi></mtd></mtr>
  180. <mtr><mtd style="height: 1rem"><mi>f</mi></mtd></mtr>
  181. <mtr><mtd style="height: 1rem"><mi>j</mi></mtd></mtr>
  182. </mtable>
  183. <mo>]</mo>
  184. </mrow>
  185. </math>, and
  186. <math>
  187. <mrow>
  188. <mi>zAxis</mi>
  189. <mo>=</mo>
  190. <mo>[</mo>
  191. <mtable>
  192. <mtr><mtd style="height: 1rem"><mi>c</mi></mtd></mtr>
  193. <mtr><mtd style="height: 1rem"><mi>g</mi></mtd></mtr>
  194. <mtr><mtd style="height: 1rem"><mi>k</mi></mtd></mtr>
  195. </mtable>
  196. <mo>]</mo>
  197. </mrow>
  198. </math>
  199. </p>
  200. <h3>[method:this extractRotation]( [param:Matrix4 m] )</h3>
  201. <p>
  202. 将给定矩阵[page:Matrix4 m]的旋转分量提取到该矩阵的旋转分量中。
  203. </p>
  204. <h3>[method:this fromArray]( [param:Array array], [param:Integer offset] )</h3>
  205. <p>
  206. [page:Array array] - 用来存储设置元素数据的数组<br />
  207. [page:Integer offset] - (可选参数) 数组的偏移量,默认值为 0。<br /><br />
  208. 使用基于列优先格式[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]的数组来设置该矩阵。
  209. </p>
  210. <h3>[method:this invert]()</h3>
  211. <p>
  212. 将当前矩阵翻转为它的逆矩阵,使用 [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method] 解析方式。你不能对行或列为 0 的矩阵进行翻转,如果你尝试这样做,该方法将生成一个零矩阵。
  213. </p>
  214. <h3>[method:Float getMaxScaleOnAxis]()</h3>
  215. <p>获取3个轴方向的最大缩放值。</p>
  216. <h3>[method:this identity]()</h3>
  217. <p>将当前矩阵重置为单位矩阵[link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix]。</p>
  218. <h3>[method:this lookAt]( [param:Vector3 eye], [param:Vector3 target], [param:Vector3 up] )</h3>
  219. <p>
  220. 构造一个旋转矩阵,从[page:Vector3 eye] 指向 [page:Vector3 target],由向量 [page:Vector3 up] 定向。
  221. </p>
  222. <h3>[method:this makeRotationAxis]( [param:Vector3 axis], [param:Float theta] )</h3>
  223. <p>
  224. [page:Vector3 axis] — 旋转轴,需要被归一化。<br />
  225. [page:Float theta] — 旋转量(弧度)。<br /><br />
  226. 设置当前矩阵为围绕轴 [page:Vector3 axis] 旋转量为 [page:Float theta]弧度。<br />
  227. 这是一种有点争议但在数学上可以替代通过四元数[page:Quaternion Quaternions]旋转的办法。 请参阅此处[link:https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199 here]的讨论。
  228. </p>
  229. <h3>[method:this makeBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )</h3>
  230. <p>
  231. 通过给定的三个向量设置该矩阵为基矩阵[link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis]:<br /><br />
  232. <math>
  233. <mrow>
  234. <mo>[</mo>
  235. <mtable>
  236. <mtr>
  237. <mtd><mi>xAxis.x</mi></mtd>
  238. <mtd><mi>yAxis.x</mi></mtd>
  239. <mtd><mi>zAxis.x</mi></mtd>
  240. <mtd><mn>0</mn></mtd>
  241. </mtr>
  242. <mtr>
  243. <mtd><mi>xAxis.y</mi></mtd>
  244. <mtd><mi>yAxis.y</mi></mtd>
  245. <mtd><mi>zAxis.y</mi></mtd>
  246. <mtd><mn>0</mn></mtd>
  247. </mtr>
  248. <mtr>
  249. <mtd><mi>xAxis.z</mi></mtd>
  250. <mtd><mi>yAxis.z</mi></mtd>
  251. <mtd><mi>zAxis.z</mi></mtd>
  252. <mtd><mn>0</mn></mtd>
  253. </mtr>
  254. <mtr>
  255. <mtd><mn>0</mn></mtd>
  256. <mtd><mn>0</mn></mtd>
  257. <mtd><mn>0</mn></mtd>
  258. <mtd><mn>1</mn></mtd>
  259. </mtr>
  260. </mtable>
  261. <mo>]</mo>
  262. </mrow>
  263. </math>
  264. </p>
  265. <h3>[method:this makePerspective]( [param:Float left], [param:Float right], [param:Float top], [param:Float bottom], [param:Float near], [param:Float far] )</h3>
  266. <p>
  267. 创建一个透视投影矩阵[link:https://en.wikipedia.org/wiki/3D_projection#Perspective_projection perspective projection]。
  268. 在引擎内部由[page:PerspectiveCamera.updateProjectionMatrix]()使用。
  269. </p>
  270. <h3>[method:this makeOrthographic]( [param:Float left], [param:Float right], [param:Float top], [param:Float bottom], [param:Float near], [param:Float far] )</h3>
  271. <p>
  272. 创建一个正交投影矩阵[link:https://en.wikipedia.org/wiki/Orthographic_projection orthographic projection]。
  273. 在引擎内部由[page:OrthographicCamera.updateProjectionMatrix]()使用。
  274. </p>
  275. <h3>[method:this makeRotationFromEuler]( [param:Euler euler] )</h3>
  276. <p>
  277. 将传入的欧拉角转换为该矩阵的旋转分量(左上角的3x3矩阵)。
  278. 矩阵的其余部分被设为单位矩阵。根据欧拉角[page:Euler euler]的旋转顺序[page:Euler.order order],总共有六种可能的结果。
  279. 详细信息,请参阅本页[link:https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix this page]。
  280. </p>
  281. <h3>[method:this makeRotationFromQuaternion]( [param:Quaternion q] )</h3>
  282. <p>
  283. 将这个矩阵的旋转分量设置为四元数[page:Quaternion q]指定的旋转,如下链接所诉[link:https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion here]。
  284. 矩阵的其余部分被设为单位矩阵。因此,给定四元数[page:Quaternion q] = w + xi + yj + zk,得到的矩阵为:<br /><br />
  285. <math>
  286. <mrow>
  287. <mo>[</mo>
  288. <mtable>
  289. <mtr>
  290. <mtd>
  291. <mn>1</mn>
  292. <mo>-</mo>
  293. <mn>2</mn>
  294. <msup>
  295. <mi>y</mi>
  296. <mn>2</mn>
  297. </msup>
  298. <mo>-</mo>
  299. <mn>2</mn>
  300. <msup>
  301. <mi>z</mi>
  302. <mn>2</mn>
  303. </msup>
  304. </mtd>
  305. <mtd>
  306. <mn>2</mn>
  307. <mi>x</mi>
  308. <mi>y</mi>
  309. <mo>-</mo>
  310. <mn>2</mn>
  311. <mi>z</mi>
  312. <mi>w</mi>
  313. </mtd>
  314. <mtd>
  315. <mn>2</mn>
  316. <mi>x</mi>
  317. <mi>z</mi>
  318. <mo>+</mo>
  319. <mn>2</mn>
  320. <mi>y</mi>
  321. <mi>w</mi>
  322. </mtd>
  323. <mtd>
  324. <mn>0</mn>
  325. </mtd>
  326. </mtr>
  327. <mtr>
  328. <mtd>
  329. <mn>2</mn>
  330. <mi>x</mi>
  331. <mi>y</mi>
  332. <mo>+</mo>
  333. <mn>2</mn>
  334. <mi>z</mi>
  335. <mi>w</mi>
  336. </mtd>
  337. <mtd>
  338. <mn>1</mn>
  339. <mo>-</mo>
  340. <mn>2</mn>
  341. <msup>
  342. <mi>x</mi>
  343. <mn>2</mn>
  344. </msup>
  345. <mo>-</mo>
  346. <mn>2</mn>
  347. <msup>
  348. <mi>z</mi>
  349. <mn>2</mn>
  350. </msup>
  351. </mtd>
  352. <mtd>
  353. <mn>2</mn>
  354. <mi>y</mi>
  355. <mi>z</mi>
  356. <mo>-</mo>
  357. <mn>2</mn>
  358. <mi>x</mi>
  359. <mi>w</mi>
  360. </mtd>
  361. <mtd>
  362. <mn>0</mn>
  363. </mtd>
  364. </mtr>
  365. <mtr>
  366. <mtd>
  367. <mn>2</mn>
  368. <mi>x</mi>
  369. <mi>z</mi>
  370. <mo>-</mo>
  371. <mn>2</mn>
  372. <mi>y</mi>
  373. <mi>w</mi>
  374. </mtd>
  375. <mtd>
  376. <mn>2</mn>
  377. <mi>y</mi>
  378. <mi>z</mi>
  379. <mo>+</mo>
  380. <mn>2</mn>
  381. <mi>x</mi>
  382. <mi>w</mi>
  383. </mtd>
  384. <mtd>
  385. <mn>1</mn>
  386. <mo>-</mo>
  387. <mn>2</mn>
  388. <msup>
  389. <mi>x</mi>
  390. <mn>2</mn>
  391. </msup>
  392. <mo>-</mo>
  393. <mn>2</mn>
  394. <msup>
  395. <mi>y</mi>
  396. <mn>2</mn>
  397. </msup>
  398. </mtd>
  399. <mtd>
  400. <mn>0</mn>
  401. </mtd>
  402. </mtr>
  403. <mtr>
  404. <mtd><mn>0</mn></mtd>
  405. <mtd><mn>0</mn></mtd>
  406. <mtd><mn>0</mn></mtd>
  407. <mtd><mn>1</mn></mtd>
  408. </mtr>
  409. </mtable>
  410. <mo>]</mo>
  411. </mrow>
  412. </math>
  413. </p>
  414. <h3>[method:this makeRotationX]( [param:Float theta] )</h3>
  415. <p>
  416. [page:Float theta] — Rotation angle in radians.<br /><br />
  417. 把该矩阵设置为绕x轴旋转弧度[page:Float theta] (&theta;)大小的矩阵。
  418. 结果如下:<br /><br />
  419. <math>
  420. <mrow>
  421. <mo>[</mo>
  422. <mtable>
  423. <mtr>
  424. <mtd><mn>1</mn></mtd>
  425. <mtd><mn>0</mn></mtd>
  426. <mtd><mn>0</mn></mtd>
  427. <mtd><mn>0</mn></mtd>
  428. </mtr>
  429. <mtr>
  430. <mtd>
  431. <mn>0</mn>
  432. </mtd>
  433. <mtd>
  434. <mi>cos</mi>
  435. <mi>&theta;</mi>
  436. </mtd>
  437. <mtd>
  438. <mo>-</mo>
  439. <mi>sin</mi>
  440. <mi>&theta;</mi>
  441. </mtd>
  442. <mtd>
  443. <mn>0</mn>
  444. </mtd>
  445. </mtr>
  446. <mtr>
  447. <mtd>
  448. <mn>0</mn>
  449. </mtd>
  450. <mtd>
  451. <mi>sin</mi>
  452. <mi>&theta;</mi>
  453. </mtd>
  454. <mtd>
  455. <mi>cos</mi>
  456. <mi>&theta;</mi>
  457. </mtd>
  458. <mtd>
  459. <mn>0</mn>
  460. </mtd>
  461. </mtr>
  462. <mtr>
  463. <mtd><mn>0</mn></mtd>
  464. <mtd><mn>0</mn></mtd>
  465. <mtd><mn>0</mn></mtd>
  466. <mtd><mn>1</mn></mtd>
  467. </mtr>
  468. </mtable>
  469. <mo>]</mo>
  470. </mrow>
  471. </math>
  472. </p>
  473. <h3>[method:this makeRotationY]( [param:Float theta] )</h3>
  474. <p>
  475. [page:Float theta] — Rotation angle in radians.<br /><br />
  476. 把该矩阵设置为绕Y轴旋转弧度[page:Float theta] (&theta;)大小的矩阵。
  477. 结果如下:<br /><br />
  478. <math>
  479. <mrow>
  480. <mo>[</mo>
  481. <mtable>
  482. <mtr>
  483. <mtd>
  484. <mi>cos</mi>
  485. <mi>&theta;</mi>
  486. </mtd>
  487. <mtd>
  488. <mn>0</mn>
  489. </mtd>
  490. <mtd>
  491. <mi>sin</mi>
  492. <mi>&theta;</mi>
  493. </mtd>
  494. <mtd>
  495. <mn>0</mn>
  496. </mtd>
  497. </mtr>
  498. <mtr>
  499. <mtd><mn>0</mn></mtd>
  500. <mtd><mn>1</mn></mtd>
  501. <mtd><mn>0</mn></mtd>
  502. <mtd><mn>0</mn></mtd>
  503. </mtr>
  504. <mtr>
  505. <mtd>
  506. <mo>-</mo>
  507. <mi>sin</mi>
  508. <mi>&theta;</mi>
  509. </mtd>
  510. <mtd>
  511. <mn>0</mn>
  512. </mtd>
  513. <mtd>
  514. <mi>cos</mi>
  515. <mi>&theta;</mi>
  516. </mtd>
  517. <mtd>
  518. <mn>0</mn>
  519. </mtd>
  520. </mtr>
  521. <mtr>
  522. <mtd><mn>0</mn></mtd>
  523. <mtd><mn>0</mn></mtd>
  524. <mtd><mn>0</mn></mtd>
  525. <mtd><mn>1</mn></mtd>
  526. </mtr>
  527. </mtable>
  528. <mo>]</mo>
  529. </mrow>
  530. </math>
  531. </p>
  532. <h3>[method:this makeRotationZ]( [param:Float theta] )</h3>
  533. <p>
  534. [page:Float theta] — Rotation angle in radians.<br /><br />
  535. 把该矩阵设置为绕z轴旋转弧度[page:Float theta] (&theta;)大小的矩阵。
  536. 结果如下:<br /><br />
  537. <math>
  538. <mrow>
  539. <mo>[</mo>
  540. <mtable>
  541. <mtr>
  542. <mtd>
  543. <mi>cos</mi>
  544. <mi>&theta;</mi>
  545. </mtd>
  546. <mtd>
  547. <mo>-</mo>
  548. <mi>sin</mi>
  549. <mi>&theta;</mi>
  550. </mtd>
  551. <mtd>
  552. <mn>0</mn>
  553. </mtd>
  554. <mtd>
  555. <mn>0</mn>
  556. </mtd>
  557. </mtr>
  558. <mtr>
  559. <mtd>
  560. <mi>sin</mi>
  561. <mi>&theta;</mi>
  562. </mtd>
  563. <mtd>
  564. <mi>cos</mi>
  565. <mi>&theta;</mi>
  566. </mtd>
  567. <mtd>
  568. <mn>0</mn>
  569. </mtd>
  570. <mtd>
  571. <mn>0</mn>
  572. </mtd>
  573. </mtr>
  574. <mtr>
  575. <mtd><mn>0</mn></mtd>
  576. <mtd><mn>0</mn></mtd>
  577. <mtd><mn>1</mn></mtd>
  578. <mtd><mn>0</mn></mtd>
  579. </mtr>
  580. <mtr>
  581. <mtd><mn>0</mn></mtd>
  582. <mtd><mn>0</mn></mtd>
  583. <mtd><mn>0</mn></mtd>
  584. <mtd><mn>1</mn></mtd>
  585. </mtr>
  586. </mtable>
  587. <mo>]</mo>
  588. </mrow>
  589. </math>
  590. </p>
  591. <h3>[method:this makeScale]( [param:Float x], [param:Float y], [param:Float z] )</h3>
  592. <p>
  593. [page:Float x] - 在X轴方向的缩放比。<br />
  594. [page:Float y] - 在Y轴方向的缩放比。<br />
  595. [page:Float z] - 在Z轴方向的缩放比。<br /><br />
  596. 将这个矩阵设置为缩放变换:<br /><br />
  597. <math>
  598. <mrow>
  599. <mo>[</mo>
  600. <mtable>
  601. <mtr>
  602. <mtd><mi>x</mi></mtd>
  603. <mtd><mn>0</mn></mtd>
  604. <mtd><mn>0</mn></mtd>
  605. <mtd><mn>0</mn></mtd>
  606. </mtr>
  607. <mtr>
  608. <mtd><mn>0</mn></mtd>
  609. <mtd><mi>y</mi></mtd>
  610. <mtd><mn>0</mn></mtd>
  611. <mtd><mn>0</mn></mtd>
  612. </mtr>
  613. <mtr>
  614. <mtd><mn>0</mn></mtd>
  615. <mtd><mn>0</mn></mtd>
  616. <mtd><mi>z</mi></mtd>
  617. <mtd><mn>0</mn></mtd>
  618. </mtr>
  619. <mtr>
  620. <mtd><mn>0</mn></mtd>
  621. <mtd><mn>0</mn></mtd>
  622. <mtd><mn>0</mn></mtd>
  623. <mtd><mn>1</mn></mtd>
  624. </mtr>
  625. </mtable>
  626. <mo>]</mo>
  627. </mrow>
  628. </math>
  629. </p>
  630. <h3>[method:this makeShear]( [param:Float x], [param:Float y], [param:Float z] )</h3>
  631. <p>
  632. [page:Float x] - 在X轴上剪切的量。<br />
  633. [page:Float y] - 在Y轴上剪切的量。<br />
  634. [page:Float z] - 在Z轴上剪切的量。<br /><br />
  635. 将此矩阵设置为剪切变换:<br /><br />
  636. <math>
  637. <mrow>
  638. <mo>[</mo>
  639. <mtable>
  640. <mtr>
  641. <mtd><mn>1</mn></mtd>
  642. <mtd><mi>y</mi><mi>x</mi></mtd>
  643. <mtd><mi>z</mi><mi>x</mi></mtd>
  644. <mtd><mn>0</mn></mtd>
  645. </mtr>
  646. <mtr>
  647. <mtd><mi>x</mi><mi>y</mi></mtd>
  648. <mtd><mn>1</mn></mtd>
  649. <mtd><mi>z</mi><mi>y</mi></mtd>
  650. <mtd><mn>0</mn></mtd>
  651. </mtr>
  652. <mtr>
  653. <mtd><mi>x</mi><mi>z</mi></mtd>
  654. <mtd><mi>y</mi><mi>z</mi></mtd>
  655. <mtd><mn>1</mn></mtd>
  656. <mtd><mn>0</mn></mtd>
  657. </mtr>
  658. <mtr>
  659. <mtd><mn>0</mn></mtd>
  660. <mtd><mn>0</mn></mtd>
  661. <mtd><mn>0</mn></mtd>
  662. <mtd><mn>1</mn></mtd>
  663. </mtr>
  664. </mtable>
  665. <mo>]</mo>
  666. </mrow>
  667. </math>
  668. </p>
  669. <h3>[method:this makeTranslation]( [param:Vector3 v] )</h3>
  670. <h3>
  671. [method:this makeTranslation]( [param:Float x], [param:Float y], [param:Float z] ) // optional API
  672. </h3>
  673. <p>
  674. 取传入参数[param:Vector3 v]中值设设置该矩阵为平移变换:<br /><br />
  675. <math>
  676. <mrow>
  677. <mo>[</mo>
  678. <mtable>
  679. <mtr>
  680. <mtd><mn>1</mn></mtd>
  681. <mtd><mn>0</mn></mtd>
  682. <mtd><mn>0</mn></mtd>
  683. <mtd><mi>x</mi></mtd>
  684. </mtr>
  685. <mtr>
  686. <mtd><mn>0</mn></mtd>
  687. <mtd><mn>1</mn></mtd>
  688. <mtd><mn>0</mn></mtd>
  689. <mtd><mi>y</mi></mtd>
  690. </mtr>
  691. <mtr>
  692. <mtd><mn>0</mn></mtd>
  693. <mtd><mn>0</mn></mtd>
  694. <mtd><mn>1</mn></mtd>
  695. <mtd><mi>z</mi></mtd>
  696. </mtr>
  697. <mtr>
  698. <mtd><mn>0</mn></mtd>
  699. <mtd><mn>0</mn></mtd>
  700. <mtd><mn>0</mn></mtd>
  701. <mtd><mn>1</mn></mtd>
  702. </mtr>
  703. </mtable>
  704. <mo>]</mo>
  705. </mrow>
  706. </math>
  707. </p>
  708. <h3>[method:this multiply]( [param:Matrix4 m] )</h3>
  709. <p>将当前矩阵乘以矩阵[page:Matrix4 m]。</p>
  710. <h3>[method:this multiplyMatrices]( [param:Matrix4 a], [param:Matrix4 b] )</h3>
  711. <p>设置当前矩阵为矩阵[page:Matrix4 a] x 矩阵[page:Matrix4 b]。</p>
  712. <h3>[method:this multiplyScalar]( [param:Float s] )</h3>
  713. <p>当前矩阵所有的元素乘以该缩放值*s*</p>
  714. <h3>[method:this premultiply]( [param:Matrix4 m] )</h3>
  715. <p>将矩阵[page:Matrix4 m]乘以当前矩阵。</p>
  716. <h3>[method:this scale]( [param:Vector3 v] )</h3>
  717. <p>将该矩阵的列向量乘以对应向量[page:Vector3 v]的分量。</p>
  718. <h3>[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] )</h3>
  719. <p>
  720. 以行优先的格式将传入的数值设置给该矩阵中的元素[page:.elements elements]。
  721. </p>
  722. <h3>[method:this setFromMatrix3]( [param:Matrix3 m] )</h3>
  723. <p>根据参数 [page:Matrix3 m] 的值,设置当前矩阵左上 3x3 的矩阵值。</p>
  724. <h3>[method:this setPosition]( [param:Vector3 v] )</h3>
  725. <h3>[method:this setPosition]( [param:Float x], [param:Float y], [param:Float z] ) // optional API</h3>
  726. <p>
  727. 取传入参数[param:Vector3 v]中值设置该矩阵的位置分量,不影响该矩阵的其余部分——即,如果该矩阵当前为:<br /><br />
  728. <math>
  729. <mrow>
  730. <mo>[</mo>
  731. <mtable>
  732. <mtr>
  733. <mtd><mi>a</mi></mtd>
  734. <mtd><mi>b</mi></mtd>
  735. <mtd><mi>c</mi></mtd>
  736. <mtd><mi>d</mi></mtd>
  737. </mtr>
  738. <mtr>
  739. <mtd><mi>e</mi></mtd>
  740. <mtd><mi>f</mi></mtd>
  741. <mtd><mi>g</mi></mtd>
  742. <mtd><mi>h</mi></mtd>
  743. </mtr>
  744. <mtr>
  745. <mtd><mi>i</mi></mtd>
  746. <mtd><mi>j</mi></mtd>
  747. <mtd><mi>k</mi></mtd>
  748. <mtd><mi>l</mi></mtd>
  749. </mtr>
  750. <mtr>
  751. <mtd><mi>m</mi></mtd>
  752. <mtd><mi>n</mi></mtd>
  753. <mtd><mi>o</mi></mtd>
  754. <mtd><mi>p</mi></mtd>
  755. </mtr>
  756. </mtable>
  757. <mo>]</mo>
  758. </mrow>
  759. </math><br /><br />
  760. 变成:<br /><br />
  761. <math>
  762. <mrow>
  763. <mo>[</mo>
  764. <mtable>
  765. <mtr>
  766. <mtd><mi>a</mi></mtd>
  767. <mtd><mi>b</mi></mtd>
  768. <mtd><mi>c</mi></mtd>
  769. <mtd><mi>v.x</mi></mtd>
  770. </mtr>
  771. <mtr>
  772. <mtd><mi>e</mi></mtd>
  773. <mtd><mi>f</mi></mtd>
  774. <mtd><mi>g</mi></mtd>
  775. <mtd><mi>v.y</mi></mtd>
  776. </mtr>
  777. <mtr>
  778. <mtd><mi>i</mi></mtd>
  779. <mtd><mi>j</mi></mtd>
  780. <mtd><mi>k</mi></mtd>
  781. <mtd><mi>v.z</mi></mtd>
  782. </mtr>
  783. <mtr>
  784. <mtd><mi>m</mi></mtd>
  785. <mtd><mi>n</mi></mtd>
  786. <mtd><mi>o</mi></mtd>
  787. <mtd><mi>p</mi></mtd>
  788. </mtr>
  789. </mtable>
  790. <mo>]</mo>
  791. </mrow>
  792. </math>
  793. </p>
  794. <h3>[method:Array toArray]( [param:Array array], [param:Integer offset] )</h3>
  795. <p>
  796. [page:Array array] - (可选参数) 存储矩阵元素的数组,如果未指定会创建一个新的数组。<br />
  797. [page:Integer offset] - (可选参数) 存放矩阵元素数组的偏移量。<br /><br />
  798. 使用列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]格式将此矩阵的元素写入数组中。
  799. </p>
  800. <h3>[method:this transpose]()</h3>
  801. <p>将该矩阵转置[link:https://en.wikipedia.org/wiki/Transpose Transposes]。</p>
  802. <h2>源码(Source)</h2>
  803. <p>
  804. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  805. </p>
  806. </body>
  807. </html>