forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix4.html
More file actions
270 lines (215 loc) · 8.75 KB
/
Matrix4.html
File metadata and controls
270 lines (215 loc) · 8.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<div class="desc">A 4x4 Matrix.</div>
<h2>Example</h2>
<code>// Simple rig for rotating around 3 axes
var m = new THREE.Matrix4();
var m1 = new THREE.Matrix4();
var m2 = new THREE.Matrix4();
var m3 = new THREE.Matrix4();
var alpha = 0;
var beta = Math.PI;
var gamma = Math.PI/2;
m1.makeRotationX( alpha );
m2.makeRotationY( beta );
m3.makeRotationZ( gamma );
m.multiplyMatrices( m1, m2 );
m.multiply( m3 );
</code>
<h2>Constructor</h2>
<h3>[name]()</h3>
<div>
Creates and initializes the matrix to the identity matrix.
</div>
<h2>Properties</h2>
<h3>[property:Float32Array elements]</h3>
<div>A column-major list of matrix values.</div>
<h2>Methods</h2>
<h3>[method:Matrix4 set]( [page:Float n11], [page:Float n12], [page:Float n13], [page:Float n14], [page:Float n21], [page:Float n22], [page:Float n23], [page:Float n24], [page:Float n31], [page:Float n32], [page:Float n33], [page:Float n34], [page:Float n41], [page:Float n42], [page:Float n43], [page:Float n44] ) [page:Matrix4 this]</h3>
<div>
Sets all fields of this matrix to the supplied row-major values n11..n44.
</div>
<h3>[method:Matrix4 identity]() [page:Matrix4 this]</h3>
<div>
Resets this matrix to identity.
</div>
<h3>[method:Matrix4 copy]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
<div>
Copies the values of matrix *m* into this matrix.
</div>
<h3>[method:Matrix4 fromArray]( [page:Array array] ) [page:Matrix4 this]</h3>
<div>
array -- [page:Array] The array to read the elements from.
</div>
<div>
Sets the elements of this matrix based on an array in column-major format.
</div>
<h3>[method:Matrix4 copyPosition]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
<div>
Copies the translation component of the supplied matrix *m* into this matrix translation component.
</div>
<h3>[method:Matrix4 makeBasis]( [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] ) [page:Matrix4 this]</h3>
<div>
Creates the basis matrix consisting of the three provided axis vectors. Returns the current matrix.
</div>
<h3>[method:Matrix4 extractBasis]( [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] ) [page:Matrix4 this]</h3>
<div>
Extracts basis of into the three axis vectors provided. Returns the current matrix.
</div>
<h3>[method:Matrix4 extractRotation]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
<div>
Extracts the rotation of the supplied matrix *m* into this matrix rotation component.
</div>
<h3>[method:Matrix4 lookAt]( [page:Vector3 eye], [page:Vector3 center], [page:Vector3 up], ) [page:Matrix4 this]</h3>
<div>
Constructs a rotation matrix, looking from *eye* towards *center* with defined *up* vector.
</div>
<h3>[method:Matrix4 multiply]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
<div>
Post-multiplies this matrix by *m*.
</div>
<h3>[method:Matrix4 premultiply]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
<div>
Pre-multiplies this matrix by *m*.
</div>
<h3>[method:Matrix4 multiplyMatrices]( [page:Matrix4 a], [page:Matrix4 b] ) [page:Matrix4 this]</h3>
<div>
Sets this matrix to *a x b*.
</div>
<h3>[method:Matrix4 multiplyToArray]( [page:Matrix4 a], [page:Matrix4 b], [page:Array r] ) [page:Matrix4 this]</h3>
<div>
Sets this matrix to *a x b* and stores the result into the flat array *r*.<br />
*r* can be either a regular Array or a TypedArray.
</div>
<h3>[method:Matrix4 multiplyScalar]( [page:Float s] ) [page:Matrix4 this]</h3>
<div>
Multiplies every component of the matrix by a scalar value *s*.
</div>
<h3>[method:Float determinant]() [page:Matrix4 this]</h3>
<div>
Computes and returns the determinant of this matrix.<br />
Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm]
</div>
<h3>[method:Matrix4 transpose]() [page:Matrix4 this]</h3>
<div>
Transposes this matrix.
</div>
<h3>[method:Matrix4 setPosition]( [page:Vector3 v] ) [page:Matrix4 this]</h3>
<div>
Sets the position component for this matrix from vector *v*.
</div>
<h3>[method:Matrix4 getInverse]( [page:Matrix4 m] ) [page:Matrix4 this]</h3>
<div>
Sets this matrix to the inverse of matrix *m*.<br />
Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm].
</div>
<h3>[method:Matrix4 makeRotationFromEuler]( [page:Euler euler] ) [page:Matrix4 this]</h3>
<div>
euler — Rotation vector followed by order of rotations, e.g., "XYZ".
</div>
<div>
Sets the rotation submatrix of this matrix to the rotation specified by Euler angles, the rest of the matrix is identity.<br />
Default order is *"XYZ"*.
</div>
<h3>[method:Matrix4 makeRotationFromQuaternion]( [page:Quaternion q] ) [page:Matrix4 this]</h3>
<div>
Sets the rotation submatrix of this matrix to the rotation specified by *q*. The rest of the matrix is identity.
</div>
<h3>[method:Matrix4 scale]( [page:Vector3 v] ) [page:Matrix4 this]</h3>
<div>
Multiplies the columns of this matrix by vector *v*.
</div>
<h3>[method:Matrix4 compose]( [page:Vector3 translation], [page:Quaternion quaternion], [page:Vector3 scale] ) [page:Matrix4 this]</h3>
<div>
Sets this matrix to the transformation composed of *translation*, *quaternion* and *scale*.
</div>
<h3>[method:null decompose]( [page:Vector3 translation], [page:Quaternion quaternion], [page:Vector3 scale] ) [page:Matrix4 this]</h3>
<div>
Decomposes this matrix into the *translation*, *quaternion* and *scale* components.
</div>
<h3>[method:Matrix4 makeTranslation]( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4 this]</h3>
<div>
Sets this matrix as translation transform.
</div>
<h3>[method:Matrix4 makeRotationX]( [page:Float theta] ) [page:Matrix4 this]</h3>
<div>
theta — Rotation angle in radians.
</div>
<div>
Sets this matrix as rotation transform around x axis by *theta* radians.
</div>
<h3>[method:Matrix4 makeRotationY]( [page:Float theta] ) [page:Matrix4 this]</h3>
<div>
theta — Rotation angle in radians.
</div>
<div>
Sets this matrix as rotation transform around y axis by *theta* radians.
</div>
<h3>[method:Matrix4 makeRotationZ]( [page:Float theta] ) [page:Matrix4 this]</h3>
<div>
theta — Rotation angle in radians.
</div>
<div>
Sets this matrix as rotation transform around z axis by *theta* radians.
</div>
<h3>[method:Matrix4 makeRotationAxis]( [page:Vector3 axis], [page:Float theta] ) [page:Matrix4 this]</h3>
<div>
axis — Rotation axis, should be normalized.
theta — Rotation angle in radians.
</div>
<div>
Sets this matrix as rotation transform around *axis* by *angle* radians.<br />
Based on [link:http://www.gamedev.net/reference/articles/article1199.asp].
</div>
<h3>[method:Matrix4 makeScale]( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4 this]</h3>
<div>
Sets this matrix as scale transform.
</div>
<h3>[method:Matrix4 makeFrustum]( [page:Float left], [page:Float right], [page:Float bottom], [page:Float top], [page:Float near], [page:Float far] ) [page:Matrix4 this]</h3>
<div>
Creates a [page:Frustum frustum] matrix.
</div>
<h3>[method:Matrix4 makePerspective]( [page:Float fov], [page:Float aspect], [page:Float near], [page:Float far] ) [page:Matrix4 this]</h3>
<div>
Creates a perspective projection matrix.
</div>
<h3>[method:Matrix4 makeOrthographic]( [page:Float left], [page:Float right], [page:Float top], [page:Float bottom], [page:Float near], [page:Float far] ) [page:Matrix4 this]</h3>
<div>
Creates an orthographic projection matrix.
</div>
<h3>[method:Array applyToVector3Array]( [page:Array a] ) [page:Matrix4 this]</h3>
<div>
array -- An array in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...]
</div>
<div>
Multiplies (applies) this matrix to every vector3 in the array.
</div>
<h3>[method:Float getMaxScaleOnAxis]() [page:Matrix4 this]</h3>
<div>
Gets the maximum scale value of the 3 axes.
</div>
<h3>[method:Matrix4 clone]() [page:Matrix4 this]</h3>
<div>
Creates a copy of this matrix.
</div>
<h3>[method:Array toArray]( [page:Array array], [page:Integer offset] ) [page:Matrix4 this]</h3>
<div>
array -- [page:Array] optional array to store the vector <br />
offset -- [page:Integer] optional offset into the array
</div>
<div>
Writes the elements of this matrix to an array in column-major format.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>