-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMatrixStack.html
executable file
·390 lines (290 loc) · 19 KB
/
MatrixStack.html
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
<!DOCTYPE html><html xmlns:dc="http://purl.org/dc/terms/"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width"><link rel=stylesheet type="text/css" href="/style.css">
<script type="text/x-mathjax-config"> MathJax.Hub.Config({"HTML-CSS": { availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, preferredFont: "TeX" },
tex2jax: { displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ], processEscapes: true } });
</script><script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML-full"></script></head><body> <div class="header">
<nav><p><a href="#navigation">Menu</a> - <a href="#top">Top</a> - <a href="/">Home</a></nav></div>
<div class="mainarea" id="top">
<h1 id="matrixstack">MatrixStack</h1>
<p><a href="index.html">Back to documentation index.</a></p>
<p><a name="MatrixStack"></a>
### MatrixStack()</p>
<p>This class implements a stack
of 4 × 4 transformation matrices.</p>
<p>When the constructor is called, it will create a stack whose
only element is the identity matrix.</p>
<p>This class is considered a supplementary class to the
Public Domain HTML 3D Library and is not considered part of that
library.</p>
<h3 id="methods">Methods</h3>
<ul>
<li><a href="#MatrixStack_frustum">frustum</a><br />Modifies the matrix at the top of this stack by multiplying it by
a frustum matrix.</li>
<li><a href="#MatrixStack_get">get</a><br />Gets a copy of the matrix at the top of this stack.</li>
<li><a href="#MatrixStack_loadIdentity">loadIdentity</a><br />Modifies the matrix at the top of this stack by replacing it with the identity matrix.</li>
<li><a href="#MatrixStack_loadMatrix">loadMatrix</a><br />Modifies the matrix at the top of this stack by replacing it with the specified matrix.</li>
<li><a href="#MatrixStack_loadTransposeMatrix">loadTransposeMatrix</a><br />Modifies the matrix at the top of this stack by replacing it with the
transpose of the specified matrix.</li>
<li><a href="#MatrixStack_lookAt">lookAt</a><br />Modifies the matrix at the top of this stack by multiplying it by
a matrix representing a camera view.</li>
<li><a href="#MatrixStack_multMatrix">multMatrix</a><br />Modifies the matrix at the top of this stack by multiplying it by another matrix.</li>
<li><a href="#MatrixStack_ortho">ortho</a><br />Modifies the matrix at the top of this stack by multiplying it by
an orthographic projection.</li>
<li><a href="#MatrixStack_ortho2d">ortho2d</a><br />Modifies the matrix at the top of this stack by multiplying it by
a 2D orthographic projection.</li>
<li><a href="#MatrixStack_perspective">perspective</a><br />Modifies the matrix at the top of this stack by multiplying it by
a matrix that defines a perspective projection.</li>
<li><a href="#MatrixStack_pickMatrix">pickMatrix</a><br />Modifies the matrix at the top of this stack by multiplying it by
a matrix that transforms the view to a portion of the viewport.</li>
<li><a href="#MatrixStack_popMatrix">popMatrix</a><br />Removes the matrix at the top of this stack, making
the matrix beneath it the new top matrix.</li>
<li><a href="#MatrixStack_pushMatrix">pushMatrix</a><br />Makes a copy of the matrix at the top of this stack
and puts the copy on top of the stack.</li>
<li><a href="#MatrixStack_rotate">rotate</a><br />Modifies the matrix at the top of this stack by multiplying it by a rotation transformation.</li>
<li><a href="#MatrixStack_scale">scale</a><br />Modifies the matrix at the top of this stack by multiplying it by a
scaling transformation.</li>
<li><a href="#MatrixStack_translate">translate</a><br />Modifies the matrix at the top of this stack by multiplying it by a
translation transformation.</li>
</ul>
<p><a name="MatrixStack_frustum"></a>
### MatrixStack#frustum(l, r, b, t, n, f)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by
a frustum matrix.
This method is designed for enabling a <a href="tutorial-glmath.html">right-handed coordinate system</a>.</p>
<h4 id="parameters">Parameters</h4>
<ul>
<li><code>l</code> (Type: number)<br />x-coordinate of the point where the left clipping plane meets the near clipping plane.</li>
<li><code>r</code> (Type: number)<br />x-coordinate of the point where the right clipping plane meets the near clipping plane.</li>
<li><code>b</code> (Type: number)<br />y-coordinate of the point where the bottom clipping plane meets the near clipping plane.</li>
<li><code>t</code> (Type: number)<br />y-coordinate of the point where the top clipping plane meets the near clipping plane.</li>
<li><code>n</code> (Type: number)<br />The distance from the camera to the near clipping plane. Objects closer than this distance won’t be seen. This should be slightly greater than 0.</li>
<li><code>f</code> (Type: number)<br />The distance from the camera to the far clipping plane. Objects beyond this distance will be too far to be seen.</li>
</ul>
<h4 id="return-value">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_get"></a>
### MatrixStack#get()</p>
<p>Gets a copy of the matrix at the top of this stack.</p>
<h4 id="return-value-1">Return Value</h4>
<p>. (Type: Array.<number>)</p>
<p><a name="MatrixStack_loadIdentity"></a>
### MatrixStack#loadIdentity()</p>
<p>Modifies the matrix at the top of this stack by replacing it with the identity matrix.</p>
<h4 id="return-value-2">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_loadMatrix"></a>
### MatrixStack#loadMatrix(mat)</p>
<p>Modifies the matrix at the top of this stack by replacing it with the specified matrix.</p>
<h4 id="parameters-1">Parameters</h4>
<ul>
<li><code>mat</code> (Type: Array.<number>)<br />A matrix to replace the top of the stack with.</li>
</ul>
<h4 id="return-value-3">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_loadTransposeMatrix"></a>
### MatrixStack#loadTransposeMatrix(mat)</p>
<p>Modifies the matrix at the top of this stack by replacing it with the
transpose of the specified matrix.</p>
<h4 id="parameters-2">Parameters</h4>
<ul>
<li><code>mat</code> (Type: Array.<number>)<br />A matrix whose transpose will replace the top of the stack.</li>
</ul>
<h4 id="return-value-4">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_lookAt"></a>
### MatrixStack#lookAt(ex, ey, ez, cx, cy, cz, ux, uy, uz)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by
a matrix representing a camera view.
This method is designed for enabling a <a href="tutorial-glmath.html">right-handed coordinate system</a>.</p>
<h4 id="parameters-3">Parameters</h4>
<ul>
<li><code>ex</code> (Type: number)<br />x-coordinate of the camera position in world space.</li>
<li><code>ey</code> (Type: number)<br />y-coordinate of the camera position.</li>
<li><code>ez</code> (Type: number)<br />z-coordinate of the camera position.</li>
<li><code>cx</code> (Type: number)<br />x-coordinate of the position in world space that the camera is looking at.</li>
<li><code>cy</code> (Type: number)<br />y-coordinate of the position looked at.</li>
<li><code>cz</code> (Type: number)<br />z-coordinate of the position looked at.</li>
<li><code>ux</code> (Type: number)<br />x-coordinate of the up direction vector. This vector must not point in the same or opposite direction as the camera’s view direction.</li>
<li><code>uy</code> (Type: number)<br />y-coordinate of the up vector.</li>
<li><code>uz</code> (Type: number)<br />z-coordinate of the up vector.</li>
</ul>
<h4 id="return-value-5">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_multMatrix"></a>
### MatrixStack#multMatrix(mat)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by another matrix.
The matrices are multiplied such that the transformations
they describe happen in reverse order. For example, if the matrix
at the top of the stack describes a translation and the matrix
passed to this method describes a scaling, the multiplied matrix will describe
the effect of scaling then translation.</p>
<h4 id="parameters-4">Parameters</h4>
<ul>
<li><code>mat</code> (Type: Array.<number>)<br />A matrix to multiply the current one by.</li>
</ul>
<h4 id="return-value-6">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_ortho"></a>
### MatrixStack#ortho(l, r, b, t, n, f)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by
an orthographic projection.
In this projection, the left clipping plane is parallel to the right clipping
plane and the top to the bottom.</p>
<p>This method is designed for enabling a <a href="tutorial-glmath.html">right-handed coordinate system</a>.</p>
<h4 id="parameters-5">Parameters</h4>
<ul>
<li><code>l</code> (Type: number)<br />Leftmost coordinate of the 3D view.</li>
<li><code>r</code> (Type: number)<br />Rightmost coordinate of the 3D view. (Note that r can be greater than l or vice versa.)</li>
<li><code>b</code> (Type: number)<br />Bottommost coordinate of the 3D view.</li>
<li><code>t</code> (Type: number)<br />Topmost coordinate of the 3D view. (Note that t can be greater than b or vice versa.)</li>
<li><code>n</code> (Type: number)<br />Distance from the camera to the near clipping plane. A positive value means the plane is in front of the viewer.</li>
<li><code>f</code> (Type: number)<br />Distance from the camera to the far clipping plane. A positive value means the plane is in front of the viewer.</li>
</ul>
<h4 id="return-value-7">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_ortho2d"></a>
### MatrixStack#ortho2d(l, r, b, t)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by
a 2D orthographic projection.
This method is designed for enabling a <a href="tutorial-glmath.html">right-handed coordinate system</a>.</p>
<h4 id="parameters-6">Parameters</h4>
<ul>
<li><code>l</code> (Type: number)<br />Leftmost coordinate of the 2D view.</li>
<li><code>r</code> (Type: number)<br />Rightmost coordinate of the 2D view. (Note that r can be greater than l or vice versa.)</li>
<li><code>b</code> (Type: number)<br />Bottommost coordinate of the 2D view.</li>
<li><code>t</code> (Type: number)<br />Topmost coordinate of the 2D view. (Note that t can be greater than b or vice versa.)</li>
</ul>
<h4 id="return-value-8">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_perspective"></a>
### MatrixStack#perspective(fov, aspect, n, f)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by
a matrix that defines a perspective projection.</p>
<p>This method is designed for enabling a <a href="tutorial-glmath.html">right-handed coordinate system</a>.</p>
<h4 id="parameters-7">Parameters</h4>
<ul>
<li><code>fov</code> (Type: number)<br />Vertical field of view, in degrees. Should be less than 180 degrees. (The smaller this number, the bigger close objects appear to be. As a result, zoom can be implemented by multiplying field of view by an additional factor.)</li>
<li><code>aspect</code> (Type: number)<br />The ratio of width to height of the viewport, usually the scene’s aspect ratio.</li>
<li><code>n</code> (Type: number)<br />The distance from the camera to the near clipping plane. Objects closer than this distance won’t be seen. This should be slightly greater than 0.</li>
<li><code>f</code> (Type: number)<br />The distance from the camera to the far clipping plane. Objects beyond this distance will be too far to be seen.</li>
</ul>
<h4 id="return-value-9">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_pickMatrix"></a>
### MatrixStack#pickMatrix(wx, wy, ww, wh, vp)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by
a matrix that transforms the view to a portion of the viewport.</p>
<h4 id="parameters-8">Parameters</h4>
<ul>
<li><code>wx</code> (Type: number)<br />x-coordinate of the center of the desired viewport portion.</li>
<li><code>wy</code> (Type: number)<br />y-coordinate of the center of the desired viewport portion.</li>
<li><code>ww</code> (Type: number)<br />Width of the desired viewport portion.</li>
<li><code>wh</code> (Type: number)<br />Height of the desired viewport portion.</li>
<li><code>vp</code> (Type: Array.<number>)<br />A 4-element array giving the x- and y-coordinates of the lower-left corner followed by the width and height of a rectangle indicating the current viewport.</li>
</ul>
<h4 id="return-value-10">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_popMatrix"></a>
### MatrixStack#popMatrix()</p>
<p>Removes the matrix at the top of this stack, making
the matrix beneath it the new top matrix. Has no
effect if the stack has only one matrix.</p>
<h4 id="return-value-11">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_pushMatrix"></a>
### MatrixStack#pushMatrix()</p>
<p>Makes a copy of the matrix at the top of this stack
and puts the copy on top of the stack.</p>
<h4 id="return-value-12">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_rotate"></a>
### MatrixStack#rotate(angle, x, y, z)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by a rotation transformation.</p>
<h4 id="parameters-9">Parameters</h4>
<ul>
<li><code>angle</code> (Type: number)<br />The desired angle to rotate in degrees. If the axis of rotation points toward the viewer, the angle’s value is increasing in a counterclockwise direction.</li>
<li><code>x</code> (Type: number)<br />X-component of the axis of rotation.</li>
<li><code>y</code> (Type: number)<br />Y-component of the axis of rotation.</li>
<li><code>z</code> (Type: number)<br />Z-component of the axis of rotation.</li>
</ul>
<h4 id="return-value-13">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_scale"></a>
### MatrixStack#scale(x, y, z)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by a
scaling transformation.</p>
<h4 id="parameters-10">Parameters</h4>
<ul>
<li><code>x</code> (Type: number)<br />Scale factor along the x-axis.</li>
<li><code>y</code> (Type: number)<br />Scale factor along the y-axis.</li>
<li><code>z</code> (Type: number)<br />Scale factor along the z-axis.</li>
</ul>
<h4 id="return-value-14">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a name="MatrixStack_translate"></a>
### MatrixStack#translate(x, y, z)</p>
<p>Modifies the matrix at the top of this stack by multiplying it by a
translation transformation.</p>
<h4 id="parameters-11">Parameters</h4>
<ul>
<li><code>x</code> (Type: number)<br />Translation along the x-axis.</li>
<li><code>y</code> (Type: number)<br />Translation along the y-axis.</li>
<li><code>z</code> (Type: number)<br />Translation along the z-axis.</li>
</ul>
<h4 id="return-value-15">Return Value</h4>
<p>This object. (Type: <a href="MatrixStack.html">MatrixStack</a>)</p>
<p><a href="index.html">Back to documentation index.</a></p>
</div><nav id="navigation"><ul>
<li><a href="/">Back to start site.</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io">This site's repository (source code)</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io/issues">Post an issue or comment</a></ul>
<div class="noprint">
<p>
<a href="//twitter.com/intent/tweet">Share via Twitter</a>, <a href="//www.facebook.com/sharer/sharer.php" id="sharer">Share via Facebook</a>
</p>
</div>
<h3 id="navigation">Navigation</h3>
<ul>
<li><a href="BSplineCurve.html">BSplineCurve</a></li>
<li><a href="BSplineSurface.html">BSplineSurface</a></li>
<li><a href="BufferAccessor.html">BufferAccessor</a></li>
<li><a href="Curve.html">Curve</a></li>
<li><a href="CurveBuilder.html">CurveBuilder</a></li>
<li><a href="GraphicsPath.html">GraphicsPath</a></li>
<li><a href="H3DU.html">H3DU</a></li>
<li><a href="MathUtil.html">MathUtil</a></li>
<li><a href="MeshBuffer.html">MeshBuffer</a></li>
<li><a href="Meshes.html">Meshes</a></li>
<li><a href="PiecewiseCurve.html">PiecewiseCurve</a></li>
<li><a href="Semantic.html">Semantic</a></li>
<li><a href="ShapeGroup.html">ShapeGroup</a></li>
<li><a href="Surface.html">Surface</a></li>
<li><a href="SurfaceBuilder.html">SurfaceBuilder</a></li>
<li><a href="Transform.html">Transform</a></li>
<li><a href="extras_camera.html">module:extras/camera</a></li>
<li><a href="extras_camera.Camera.html">module:extras/camera.Camera</a></li>
<li><a href="extras_camera.InputTracker.html">module:extras/camera.InputTracker</a></li>
<li><a href="extras_createwasher.html">module:extras/createwasher</a></li>
<li><a href="extras_curvetube.html">module:extras/curvetube</a></li>
<li><a href="extras_curvetube.CurveTube.html">module:extras/curvetube.CurveTube</a></li>
<li><a href="extras_derivedcurves.html">module:extras/derivedcurves</a></li>
<li><a href="extras_evaluators.html">module:extras/evaluators</a></li>
<li><a href="extras_evaluators.Roulette.html">module:extras/evaluators.Roulette</a></li>
<li><a href="extras_evaluators.SurfaceOfRevolution.html">module:extras/evaluators.SurfaceOfRevolution</a></li>
<li><a href="extras_fourierknot.html">module:extras/fourierknot</a></li>
<li><a href="extras_gradients.html">module:extras/gradients</a></li>
<li><a href="extras_marbleshader2.html">module:extras/marbleshader2</a></li>
<li><a href="extras_matrixstack.html">module:extras/matrixstack</a></li>
<li><a href="extras_matrixstack.MatrixStack.html">module:extras/matrixstack.MatrixStack</a></li>
<li><a href="extras_moresurfaces.html">module:extras/moresurfaces</a></li>
<li><a href="extras_moresurfaces.KleinBottle.html">module:extras/moresurfaces.KleinBottle</a></li>
<li><a href="extras_moresurfaces.MoebiusStrip.html">module:extras/moresurfaces.MoebiusStrip</a></li>
<li><a href="extras_pathutil.html">module:extras/pathutil</a></li>
<li><a href="extras_randompolygon.html">module:extras/randompolygon</a></li>
<li><a href="extras_starpolygon.html">module:extras/starpolygon</a></li>
<li><a href="extras_superellipsoid.html">module:extras/superellipsoid</a></li>
<li><a href="extras_superellipsoid.Supershape.html">module:extras/superellipsoid.Supershape</a></li>
<li><a href="extras_superellipsoid.Supertoroid.html">module:extras/superellipsoid.Supertoroid</a></li>
<li><a href="extras_torusknot.html">module:extras/torusknot</a></li>
<li><a href="extras_torusknot.TorusKnot.html">module:extras/torusknot.TorusKnot</a></li>
</ul>
</nav></body></html>