123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893 |
- <!DOCTYPE html>
- <html lang="zh">
- <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">
- 表示为一个 4x4 [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].<br /><br />
- 在3D计算机图形学中,4x4矩阵最常用的用法是作为一个变换矩阵[link:https://en.wikipedia.org/wiki/Transformation_matrix Transformation Matrix]。
- 有关WebGL中使用的变换矩阵的介绍,请参阅本教程[link:http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices this tutorial]。<br /><br />
- 这使得表示三维空间中的一个点的向量[page:Vector3]通过乘以矩阵来进行转换,如平移、旋转、剪切、缩放、反射、正交或透视投影等。这就是把矩阵<em>应用</em>到向量上。<br /><br />
- 任何3D物体[page:Object3D]都有三个关联的矩阵:
- <ul>
- <li>
- [page:Object3D.matrix]: 存储物体的本地变换矩阵。 这是对象相对于其父对象的变换矩阵。
- </li>
- <li>
- [page:Object3D.matrixWorld]: 对象的全局或世界变换矩阵。如果对象没有父对象,那么这与存储在矩阵[page:Object3D.matrix matrix]中的本地变换矩阵相同。
- </li>
- <li>
- [page:Object3D.modelViewMatrix]: 表示对象相对于摄像机坐标系的变换矩阵,
- 一个对象的 modelViewMatrix 是物体世界变换矩阵乘以摄像机相对于世界空间变换矩阵的逆矩阵。
- </li>
- </ul>
- 摄像机[page:Camera Cameras] 有三个额外的四维矩阵:
- <ul>
- <li>
- [page:Camera.matrixWorldInverse]: 视矩阵 - 摄像机世界坐标变换的逆矩阵。
- </li>
- <li>
- [page:Camera.projectionMatrix]: 投影变换矩阵,表示将场景中的信息投影到裁剪空间。
- </li>
- <li>
- [page:Camera.projectionMatrixInverse]: 投影变换矩阵的逆矩阵。
- </li>
- </ul>
- 注意:物体的正规矩阵 [page:Object3D.normalMatrix] 并不是一个4维矩阵,而是一个三维矩阵[page:Matrix3]。
- </p>
- <h2>注意行优先列优先的顺序。</h2>
- <p>
- 设置[page:.set set]()方法参数采用行优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major],
- 而它们在内部是用列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]顺序存储在数组当中。<br /><br />
- 这意味着
- <code>
- const m = new THREE.Matrix4();
- m.set( 11, 12, 13, 14,
- 21, 22, 23, 24,
- 31, 32, 33, 34,
- 41, 42, 43, 44 );
- </code>
- 元素数组[page:.elements elements]将存储为:
- <code>
- m.elements = [ 11, 21, 31, 41,
- 12, 22, 32, 42,
- 13, 23, 33, 43,
- 14, 24, 34, 44 ];
- </code>
- 在内部,所有的计算都是使用列优先顺序进行的。然而,由于实际的排序在数学上没有什么不同,
- 而且大多数人习惯于以行优先顺序考虑矩阵,所以three.js文档以行为主的顺序显示矩阵。
- 请记住,如果您正在阅读源代码,您必须对这里列出的任何矩阵进行转置[link:https://en.wikipedia.org/wiki/Transpose transpose],以理解计算。
- </p>
- <h2>提取位置(平移)、旋转和缩放</h2>
- <p>
- 有多种选项可用于从 Matrix4 中提取位置、旋转和缩放。
- <ul>
- <li>
- [page:Vector3.setFromMatrixPosition]:可用于提取位置相关的分量。
- </li>
- <li>
- [page:Vector3.setFromMatrixScale]:可用于提取缩放相关的分量。
- </li>
- <li>
- [page:Quaternion.setFromRotationMatrix], [page:Euler.setFromRotationMatrix] 或 [page:.extractRotation extractRotation]:可用于从纯(未缩放)矩阵中提取旋转相关分量。
- </li>
- <li>
- [page:.decompose decompose]:可用于一次性提取位置、旋转和缩放
- </li>
- </ul>
- </p>
- <h2>构造器(Constructor)</h2>
- <h3>[name]( [param:Number n11], [param:Number n12], [param:Number n13], [param:Number n14],
- [param:Number n21], [param:Number n22], [param:Number n23], [param:Number n24],
- [param:Number n31], [param:Number n32], [param:Number n33], [param:Number n34],
- [param:Number n41], [param:Number n42], [param:Number n43], [param:Number n44] )</h3>
- <p>
- Creates a 4x4 matrix with the given arguments in row-major order. If no arguments are provided, the constructor initializes
- the [name] to the 4x4 [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
- </p>
- <h2>属性(Properties)</h2>
- <h3>[property:Array elements]</h3>
- <p>
- 矩阵列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major]列表。
- </p>
- <h2>方法(Methods)</h2>
- <h3>[method:Matrix4 clone]()</h3>
- <p>创建一个新的矩阵,元素[page:.elements elements]与该矩阵相同。</p>
- <h3>[method:this compose]( [param:Vector3 position], [param:Quaternion quaternion], [param:Vector3 scale] )</h3>
- <p>
- 设置将该对象位置 [page:Vector3 position],四元数[page:Quaternion quaternion] 和 缩放[page:Vector3 scale] 组合变换的矩阵。
- </p>
- <h3>[method:this copy]( [param:Matrix4 m] )</h3>
- <p>将矩阵[page:Matrix3 m]的元素[page:.elements elements]复制到当前矩阵中。</p>
- <h3>[method:this copyPosition]( [param:Matrix4 m] )</h3>
- <p>
- 将给定矩阵 [param:Matrix4 m] 的平移分量拷贝到当前矩阵中。
- </p>
- <h3>[method:this decompose]( [param:Vector3 position], [param:Quaternion quaternion], [param:Vector3 scale] )</h3>
- <p>
- 将矩阵分解到给定的平移[page:Vector3 position] ,旋转 [page:Quaternion quaternion],缩放[page:Vector3 scale]分量中。<br/><br/>
- 注意:并非所有矩阵都可以通过这种方式分解。 例如,如果一个对象有一个非均匀缩放的父对象,那么该对象的世界矩阵可能是不可分解的,这种方法可能不合适。
- </p>
- <h3>[method:Float determinant]()</h3>
- <p>
- 计算并返回矩阵的行列式[link:https://en.wikipedia.org/wiki/Determinant determinant] 。<br /><br />
- 基于这个的方法概述[link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm here]。
- </p>
- <h3>[method:Boolean equals]( [param:Matrix4 m] )</h3>
- <p>如果矩阵[page:Matrix3 m] 与当前矩阵所有对应元素相同则返回true。</p>
- <h3>[method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )</h3>
- <p>
- 将矩阵的基向量[link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis]提取到指定的3个轴向量中。
- 如果矩阵如下:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd><mi>a</mi></mtd>
- <mtd><mi>b</mi></mtd>
- <mtd><mi>c</mi></mtd>
- <mtd><mi>d</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>e</mi></mtd>
- <mtd><mi>f</mi></mtd>
- <mtd><mi>g</mi></mtd>
- <mtd><mi>h</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>i</mi></mtd>
- <mtd><mi>j</mi></mtd>
- <mtd><mi>k</mi></mtd>
- <mtd><mi>l</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>m</mi></mtd>
- <mtd><mi>n</mi></mtd>
- <mtd><mi>o</mi></mtd>
- <mtd><mi>p</mi></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <p>然后x轴y轴z轴被设为:</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>e</mi></mtd></mtr>
- <mtr><mtd style="height: 1rem"><mi>i</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>f</mi></mtd></mtr>
- <mtr><mtd style="height: 1rem"><mi>j</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>g</mi></mtd></mtr>
- <mtr><mtd style="height: 1rem"><mi>k</mi></mtd></mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- </div>
- <h3>[method:this extractRotation]( [param:Matrix4 m] )</h3>
- <p>
- 将给定矩阵[page:Matrix4 m]的旋转分量提取到该矩阵的旋转分量中。
- </p>
- <h3>[method:this fromArray]( [param:Array array], [param:Integer offset] )</h3>
- <p>
- [page:Array array] - 用来存储设置元素数据的数组<br />
- [page:Integer offset] - (可选参数) 数组的偏移量,默认值为 0。<br /><br />
- 使用基于列优先格式[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]的数组来设置该矩阵。
- </p>
- <h3>[method:this invert]()</h3>
- <p>
- 将当前矩阵翻转为它的逆矩阵,使用 [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method] 解析方式。你不能对行或列为 0 的矩阵进行翻转,如果你尝试这样做,该方法将生成一个零矩阵。
- </p>
- <h3>[method:Float getMaxScaleOnAxis]()</h3>
- <p>获取3个轴方向的最大缩放值。</p>
- <h3>[method:this identity]()</h3>
- <p>将当前矩阵重置为单位矩阵[link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix]。</p>
- <h3>[method:this lookAt]( [param:Vector3 eye], [param:Vector3 target], [param:Vector3 up] )</h3>
- <p>
- 构造一个旋转矩阵,从[page:Vector3 eye] 指向 [page:Vector3 target],由向量 [page:Vector3 up] 定向。
- </p>
- <h3>[method:this makeRotationAxis]( [param:Vector3 axis], [param:Float theta] )</h3>
- <p>
- [page:Vector3 axis] — 旋转轴,需要被归一化。<br />
- [page:Float theta] — 旋转量(弧度)。<br /><br />
- 设置当前矩阵为围绕轴 [page:Vector3 axis] 旋转量为 [page:Float theta]弧度。<br />
- 这是一种有点争议但在数学上可以替代通过四元数[page:Quaternion Quaternions]旋转的办法。 请参阅此处[link:https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199 here]的讨论。
- </p>
- <h3>[method:this makeBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )</h3>
- <p>
- 通过给定的三个向量设置该矩阵为基矩阵[link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis]:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd><mi>xAxis.x</mi></mtd>
- <mtd><mi>yAxis.x</mi></mtd>
- <mtd><mi>zAxis.x</mi></mtd>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd><mi>xAxis.y</mi></mtd>
- <mtd><mi>yAxis.y</mi></mtd>
- <mtd><mi>zAxis.y</mi></mtd>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd><mi>xAxis.z</mi></mtd>
- <mtd><mi>yAxis.z</mi></mtd>
- <mtd><mi>zAxis.z</mi></mtd>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <h3>[method:this makePerspective]( [param:Float left], [param:Float right], [param:Float top], [param:Float bottom], [param:Float near], [param:Float far] )</h3>
- <p>
- 创建一个透视投影矩阵[link:https://en.wikipedia.org/wiki/3D_projection#Perspective_projection perspective projection]。
- 在引擎内部由[page:PerspectiveCamera.updateProjectionMatrix]()使用。
- </p>
- <h3>[method:this makeOrthographic]( [param:Float left], [param:Float right], [param:Float top], [param:Float bottom], [param:Float near], [param:Float far] )</h3>
- <p>
- 创建一个正交投影矩阵[link:https://en.wikipedia.org/wiki/Orthographic_projection orthographic projection]。
- 在引擎内部由[page:OrthographicCamera.updateProjectionMatrix]()使用。
- </p>
- <h3>[method:this makeRotationFromEuler]( [param:Euler euler] )</h3>
- <p>
- 将传入的欧拉角转换为该矩阵的旋转分量(左上角的3x3矩阵)。
- 矩阵的其余部分被设为单位矩阵。根据欧拉角[page:Euler euler]的旋转顺序[page:Euler.order order],总共有六种可能的结果。
- 详细信息,请参阅本页[link:https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix this page]。
- </p>
- <h3>[method:this makeRotationFromQuaternion]( [param:Quaternion q] )</h3>
- <p>
- 将这个矩阵的旋转分量设置为四元数[page:Quaternion q]指定的旋转,如下链接所诉[link:https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion here]。
- 矩阵的其余部分被设为单位矩阵。因此,给定四元数[page:Quaternion q] = w + xi + yj + zk,得到的矩阵为:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd>
- <mn>1</mn>
- <mo>-</mo>
- <mn>2</mn>
- <msup>
- <mi>y</mi>
- <mn>2</mn>
- </msup>
- <mo>-</mo>
- <mn>2</mn>
- <msup>
- <mi>z</mi>
- <mn>2</mn>
- </msup>
- </mtd>
- <mtd>
- <mn>2</mn>
- <mi>x</mi>
- <mi>y</mi>
- <mo>-</mo>
- <mn>2</mn>
- <mi>z</mi>
- <mi>w</mi>
- </mtd>
- <mtd>
- <mn>2</mn>
- <mi>x</mi>
- <mi>z</mi>
- <mo>+</mo>
- <mn>2</mn>
- <mi>y</mi>
- <mi>w</mi>
- </mtd>
- <mtd>
- <mn>0</mn>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mn>2</mn>
- <mi>x</mi>
- <mi>y</mi>
- <mo>+</mo>
- <mn>2</mn>
- <mi>z</mi>
- <mi>w</mi>
- </mtd>
- <mtd>
- <mn>1</mn>
- <mo>-</mo>
- <mn>2</mn>
- <msup>
- <mi>x</mi>
- <mn>2</mn>
- </msup>
- <mo>-</mo>
- <mn>2</mn>
- <msup>
- <mi>z</mi>
- <mn>2</mn>
- </msup>
- </mtd>
- <mtd>
- <mn>2</mn>
- <mi>y</mi>
- <mi>z</mi>
- <mo>-</mo>
- <mn>2</mn>
- <mi>x</mi>
- <mi>w</mi>
- </mtd>
- <mtd>
- <mn>0</mn>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mn>2</mn>
- <mi>x</mi>
- <mi>z</mi>
- <mo>-</mo>
- <mn>2</mn>
- <mi>y</mi>
- <mi>w</mi>
- </mtd>
- <mtd>
- <mn>2</mn>
- <mi>y</mi>
- <mi>z</mi>
- <mo>+</mo>
- <mn>2</mn>
- <mi>x</mi>
- <mi>w</mi>
- </mtd>
- <mtd>
- <mn>1</mn>
- <mo>-</mo>
- <mn>2</mn>
- <msup>
- <mi>x</mi>
- <mn>2</mn>
- </msup>
- <mo>-</mo>
- <mn>2</mn>
- <msup>
- <mi>y</mi>
- <mn>2</mn>
- </msup>
- </mtd>
- <mtd>
- <mn>0</mn>
- </mtd>
- </mtr>
- <mtr>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <h3>[method:this makeRotationX]( [param:Float theta] )</h3>
- <p>
- [page:Float theta] — Rotation angle in radians.<br /><br />
- 把该矩阵设置为绕x轴旋转弧度[page:Float theta] (θ)大小的矩阵。
- 结果如下:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd><mn>1</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd>
- <mn>0</mn>
- </mtd>
- <mtd>
- <mi>cos</mi>
- <mi>θ</mi>
- </mtd>
- <mtd>
- <mo>-</mo>
- <mi>sin</mi>
- <mi>θ</mi>
- </mtd>
- <mtd>
- <mn>0</mn>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mn>0</mn>
- </mtd>
- <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>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <h3>[method:this makeRotationY]( [param:Float theta] )</h3>
- <p>
- [page:Float theta] — Rotation angle in radians.<br /><br />
- 把该矩阵设置为绕Y轴旋转弧度[page:Float theta] (θ)大小的矩阵。
- 结果如下:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd>
- <mi>cos</mi>
- <mi>θ</mi>
- </mtd>
- <mtd>
- <mn>0</mn>
- </mtd>
- <mtd>
- <mi>sin</mi>
- <mi>θ</mi>
- </mtd>
- <mtd>
- <mn>0</mn>
- </mtd>
- </mtr>
- <mtr>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd>
- <mo>-</mo>
- <mi>sin</mi>
- <mi>θ</mi>
- </mtd>
- <mtd>
- <mn>0</mn>
- </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>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <h3>[method:this makeRotationZ]( [param:Float theta] )</h3>
- <p>
- [page:Float theta] — Rotation angle in radians.<br /><br />
- 把该矩阵设置为绕z轴旋转弧度[page:Float theta] (θ)大小的矩阵。
- 结果如下:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd>
- <mi>cos</mi>
- <mi>θ</mi>
- </mtd>
- <mtd>
- <mo>-</mo>
- <mi>sin</mi>
- <mi>θ</mi>
- </mtd>
- <mtd>
- <mn>0</mn>
- </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>
- <mtd>
- <mn>0</mn>
- </mtd>
- </mtr>
- <mtr>
- <mtd><mn>0</mn></mtd>
- <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>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <h3>[method:this makeScale]( [param:Float x], [param:Float y], [param:Float z] )</h3>
- <p>
- [page:Float x] - 在X轴方向的缩放比。<br />
- [page:Float y] - 在Y轴方向的缩放比。<br />
- [page:Float z] - 在Z轴方向的缩放比。<br /><br />
- 将这个矩阵设置为缩放变换:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd><mi>x</mi></mtd>
- <mtd><mn>0</mn></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>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mi>z</mi></mtd>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <h3>[method:this makeShear]( [param:Float x], [param:Float y], [param:Float z] )</h3>
- <p>
- [page:Float x] - 在X轴上剪切的量。<br />
- [page:Float y] - 在Y轴上剪切的量。<br />
- [page:Float z] - 在Z轴上剪切的量。<br /><br />
- 将此矩阵设置为剪切变换:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd><mn>1</mn></mtd>
- <mtd><mi>y</mi><mi>x</mi></mtd>
- <mtd><mi>z</mi><mi>x</mi></mtd>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd><mi>x</mi><mi>y</mi></mtd>
- <mtd><mn>1</mn></mtd>
- <mtd><mi>z</mi><mi>y</mi></mtd>
- <mtd><mn>0</mn></mtd>
- </mtr>
- <mtr>
- <mtd><mi>x</mi><mi>z</mi></mtd>
- <mtd><mi>y</mi><mi>z</mi></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>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <h3>[method:this makeTranslation]( [param:Vector3 v] )</h3>
- <h3>
- [method:this makeTranslation]( [param:Float x], [param:Float y], [param:Float z] ) // optional API
- </h3>
- <p>
- 取传入参数[param:Vector3 v]中值设设置该矩阵为平移变换:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd><mn>1</mn></mtd>
- <mtd><mn>0</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><mn>0</mn></mtd>
- <mtd><mi>y</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>0</mn></mtd>
- <mtd><mn>1</mn></mtd>
- <mtd><mi>z</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mn>0</mn></mtd>
- <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:Matrix4 m] )</h3>
- <p>将当前矩阵乘以矩阵[page:Matrix4 m]。</p>
- <h3>[method:this multiplyMatrices]( [param:Matrix4 a], [param:Matrix4 b] )</h3>
- <p>设置当前矩阵为矩阵[page:Matrix4 a] x 矩阵[page:Matrix4 b]。</p>
- <h3>[method:this multiplyScalar]( [param:Float s] )</h3>
- <p>当前矩阵所有的元素乘以该缩放值*s*</p>
- <h3>[method:this premultiply]( [param:Matrix4 m] )</h3>
- <p>将矩阵[page:Matrix4 m]乘以当前矩阵。</p>
- <h3>[method:this scale]( [param:Vector3 v] )</h3>
- <p>将该矩阵的列向量乘以对应向量[page:Vector3 v]的分量。</p>
- <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>
- <p>
- 以行优先的格式将传入的数值设置给该矩阵中的元素[page:.elements elements]。
- </p>
- <h3>[method:this setFromMatrix3]( [param:Matrix3 m] )</h3>
- <p>根据参数 [page:Matrix3 m] 的值,设置当前矩阵左上 3x3 的矩阵值。</p>
- <h3>[method:this setPosition]( [param:Vector3 v] )</h3>
- <h3>[method:this setPosition]( [param:Float x], [param:Float y], [param:Float z] ) // optional API</h3>
- <p>
- 取传入参数[param:Vector3 v]中值设置该矩阵的位置分量,不影响该矩阵的其余部分——即,如果该矩阵当前为:
- </p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd><mi>a</mi></mtd>
- <mtd><mi>b</mi></mtd>
- <mtd><mi>c</mi></mtd>
- <mtd><mi>d</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>e</mi></mtd>
- <mtd><mi>f</mi></mtd>
- <mtd><mi>g</mi></mtd>
- <mtd><mi>h</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>i</mi></mtd>
- <mtd><mi>j</mi></mtd>
- <mtd><mi>k</mi></mtd>
- <mtd><mi>l</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>m</mi></mtd>
- <mtd><mi>n</mi></mtd>
- <mtd><mi>o</mi></mtd>
- <mtd><mi>p</mi></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <p>变成:</p>
- <math display="block">
- <mrow>
- <mo>[</mo>
- <mtable>
- <mtr>
- <mtd><mi>a</mi></mtd>
- <mtd><mi>b</mi></mtd>
- <mtd><mi>c</mi></mtd>
- <mtd><mi>v.x</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>e</mi></mtd>
- <mtd><mi>f</mi></mtd>
- <mtd><mi>g</mi></mtd>
- <mtd><mi>v.y</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>i</mi></mtd>
- <mtd><mi>j</mi></mtd>
- <mtd><mi>k</mi></mtd>
- <mtd><mi>v.z</mi></mtd>
- </mtr>
- <mtr>
- <mtd><mi>m</mi></mtd>
- <mtd><mi>n</mi></mtd>
- <mtd><mi>o</mi></mtd>
- <mtd><mi>p</mi></mtd>
- </mtr>
- </mtable>
- <mo>]</mo>
- </mrow>
- </math>
- <h3>[method:Array toArray]( [param:Array array], [param:Integer offset] )</h3>
- <p>
- [page:Array array] - (可选参数) 存储矩阵元素的数组,如果未指定会创建一个新的数组。<br />
- [page:Integer offset] - (可选参数) 存放矩阵元素数组的偏移量。<br /><br />
- 使用列优先[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]格式将此矩阵的元素写入数组中。
- </p>
- <h3>[method:this transpose]()</h3>
- <p>将该矩阵转置[link:https://en.wikipedia.org/wiki/Transpose Transposes]。</p>
- <h2>源码(Source)</h2>
- <p>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </p>
- </body>
- </html>
|