1
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
2
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
3
\setcounter{chapter}{5} % Appendix F
4
%% use \begin{xmpLines} etc, not \begin{figXmpLines}
5
%% see use of \labelSpace below when heading crashes into text
6
%% you've repeat one of the section labels (ugFknot)
9
\newcommand{\ugAppGraphicsTitle}{Programs for AXIOM Images}
10
\newcommand{\ugAppGraphicsNumber}{G.}
12
% =====================================================================
13
\begin{page}{ugAppGraphicsPage}{G. Programs for AXIOM Images}
14
% =====================================================================
17
This appendix contains the \Language{} programs used to generate
18
the images in the \Gallery{} color insert of this book.
19
All these input files are included
20
with the \Language{} system.
22
on page 6 of the \Gallery{} insert, for example, issue the command:
27
These images were produced on an IBM RS/6000 model 530 with a
28
standard color graphics adapter. The smooth shaded images
29
were made from X Window System screen dumps.
30
The remaining images were produced with \Language{}-generated
31
PostScript output. The images were reproduced from slides made on an Agfa
32
ChromaScript PostScript interpreter with a Matrix Instruments QCR camera.
35
\menudownlink{{F.1. images1.input}}{ugFimagesOnePage}
36
\menudownlink{{F.2. images2.input}}{ugFimagesTwoPage}
37
\menudownlink{{F.3. images3.input}}{ugFimagesThreePage}
38
\menudownlink{{F.4. images5.input}}{ugFimagesFivePage}
39
\menudownlink{{F.5. images6.input}}{ugFimagesSixPage}
40
\menudownlink{{F.6. images7.input}}{ugFimagesSevenPage}
41
\menudownlink{{F.7. images8.input}}{ugFimagesEightPage}
42
\menudownlink{{F.8. conformal.input}}{ugFconformalPage}
43
\menudownlink{{F.9. tknot.input}}{ugFtknotPage}
44
\menudownlink{{F.10. ntube.input}}{ugFntubePage}
45
\menudownlink{{F.11. dhtri.input}}{ugFdhtriPage}
46
\menudownlink{{F.12. tetra.input}}{ugFtetraPage}
47
\menudownlink{{F.13. antoine.input}}{ugFantoinePage}
48
\menudownlink{{F.14. scherk.input}}{ugFscherkPage}
55
\newcommand{\ugFimagesOneTitle}{images1.input}
56
\newcommand{\ugFimagesOneNumber}{G.1.}
58
% =====================================================================
59
\begin{page}{ugFimagesOnePage}{G.1. images1.input}
60
% =====================================================================
67
{\tt 1.\ \ \ )read\ tknot}\newline
68
{\tt 2.\ \ \ }\newline
69
{\tt 3.\ \ \ torusKnot(15,17,\ 0.1,\ 6,\ 700)}\newline
72
%-% \HDindex{torus knot}{ugFimagesOnePage}{G.1.}{images1.input}
80
\newcommand{\ugFimagesTwoTitle}{images2.input}
81
\newcommand{\ugFimagesTwoNumber}{G.2.}
83
% =====================================================================
84
\begin{page}{ugFimagesTwoPage}{G.2. images2.input}
85
% =====================================================================
88
These images illustrate how Newton's method converges when computing the
89
%-% \HDindex{Newton iteration}{ugFimagesTwoPage}{G.2.}{images2.input}
90
complex cube roots of 2. Each point in the \smath{(x,y)}-plane represents the
91
complex number \smath{x + iy,} which is given as a starting point for Newton's
92
method. The poles in these images represent bad starting values.
93
The flat areas are the regions of convergence to the three roots.
97
{\tt 1.\ \ \ )read\ newton}\newline
98
{\tt 2.\ \ \ )read\ vectors}\newline
99
{\tt 3.\ \ \ f\ :=\ newtonStep(x**3\ -\ 2)}\newline
100
{\tt 4.\ \ \ }\newline
104
The function \texht{$f^n$}{f**n} computes $n$ steps of Newton's method.
108
{\tt 1.\ \ \ clipValue\ :=\ 4}\newline
109
{\tt 2.\ \ \ drawComplexVectorField(f**3,\ -3..3,\ -3..3)}\newline
110
{\tt 3.\ \ \ drawComplex(f**3,\ -3..3,\ -3..3)}\newline
111
{\tt 4.\ \ \ drawComplex(f**4,\ -3..3,\ -3..3)}\newline
120
\newcommand{\ugFimagesThreeTitle}{images3.input}
121
\newcommand{\ugFimagesThreeNumber}{G.3.}
123
% =====================================================================
124
\begin{page}{ugFimagesThreePage}{G.3. images3.input}
125
% =====================================================================
130
{\tt 1.\ \ \ )r\ tknot}\newline
131
{\tt 2.\ \ \ for\ i\ in\ 0..4\ repeat\ torusKnot(2,\ 2\ +\ i/4,\ 0.5,\ 25,\ 250)}\newline
140
\newcommand{\ugFimagesFiveTitle}{images5.input}
141
\newcommand{\ugFimagesFiveNumber}{G.4.}
143
% =====================================================================
144
\begin{page}{ugFimagesFivePage}{G.4. images5.input}
145
% =====================================================================
148
The parameterization of the Etruscan Venus is due to George Frances.
149
%-% \HDindex{Etruscan Venus}{ugFimagesFivePage}{G.4.}{images5.input}
153
{\tt 1.\ \ \ venus(a,r,steps)\ ==}\newline
154
{\tt 2.\ \ \ \ \ surf\ :=\ (u:DFLOAT,\ v:DFLOAT):\ Point\ DFLOAT\ +->}\newline
155
{\tt 3.\ \ \ \ \ \ \ cv\ :=\ cos(v)}\newline
156
{\tt 4.\ \ \ \ \ \ \ sv\ :=\ sin(v)}\newline
157
{\tt 5.\ \ \ \ \ \ \ cu\ :=\ cos(u)}\newline
158
{\tt 6.\ \ \ \ \ \ \ su\ :=\ sin(u)}\newline
159
{\tt 7.\ \ \ \ \ \ \ x\ :=\ r\ *\ cos(2*u)\ *\ cv\ +\ sv\ *\ cu}\newline
160
{\tt 8.\ \ \ \ \ \ \ y\ :=\ r\ *\ sin(2*u)\ *\ cv\ -\ sv\ *\ su}\newline
161
{\tt 9.\ \ \ \ \ \ \ z\ :=\ a\ *\ cv}\newline
162
{\tt 10.\ \ \ \ \ \ point\ [x,y,z]}\newline
163
{\tt 11.\ \ \ \ draw(surf,\ 0..\%pi,\ -\%pi..\%pi,\ var1Steps==steps,}\newline
164
{\tt 12.\ \ \ \ \ \ \ \ \ var2Steps==steps,\ title\ ==\ "Etruscan\ Venus")}\newline
165
{\tt 13.\ \ }\newline
166
{\tt 14.\ \ venus(5/2,\ 13/10,\ 50)}\newline
170
The Figure-8 Klein Bottle
171
%-% \HDindex{Klein bottle}{ugFimagesFivePage}{G.4.}{images5.input}
172
parameterization is from
173
``Differential Geometry and Computer Graphics'' by Thomas Banchoff,
174
in {\it Perspectives in Mathematics,} Anniversary of Oberwolfasch 1984,
175
Birkh\"{a}user-Verlag, Basel, pp. 43-60.
179
{\tt 1.\ \ \ klein(x,y)\ ==}\newline
180
{\tt 2.\ \ \ \ \ cx\ :=\ cos(x)}\newline
181
{\tt 3.\ \ \ \ \ cy\ :=\ cos(y)}\newline
182
{\tt 4.\ \ \ \ \ sx\ :=\ sin(x)}\newline
183
{\tt 5.\ \ \ \ \ sy\ :=\ sin(y)}\newline
184
{\tt 6.\ \ \ \ \ sx2\ :=\ sin(x/2)}\newline
185
{\tt 7.\ \ \ \ \ cx2\ :=\ cos(x/2)}\newline
186
{\tt 8.\ \ \ \ \ sq2\ :=\ sqrt(2.0@DFLOAT)}\newline
187
{\tt 9.\ \ \ \ \ point\ [cx\ *\ (cx2\ *\ (sq2\ +\ cy)\ +\ (sx2\ *\ sy\ *\ cy)),\ \_}\newline
188
{\tt 10.\ \ \ \ \ \ \ \ \ \ \ sx\ *\ (cx2\ *\ (sq2\ +\ cy)\ +\ (sx2\ *\ sy\ *\ cy)),\ \_}\newline
189
{\tt 11.\ \ \ \ \ \ \ \ \ \ \ -sx2\ *\ (sq2\ +\ cy)\ +\ cx2\ *\ sy\ *\ cy]}\newline
190
{\tt 12.\ \ }\newline
191
{\tt 13.\ \ draw(klein,\ 0..4*\%pi,\ 0..2*\%pi,\ var1Steps==50,}\newline
192
{\tt 14.\ \ \ \ \ \ \ var2Steps==50,title=="Figure\ Eight\ Klein\ Bottle")}\newline
196
The next two images are examples of generalized tubes.
200
{\tt 15.\ \ )read\ ntube}\newline
201
{\tt 16.\ \ rotateBy(p,\ theta)\ ==}\newline
202
{\tt 17.\ \ \ \ c\ :=\ cos(theta)}\newline
203
{\tt 18.\ \ \ \ s\ :=\ sin(theta)}\newline
204
{\tt 19.\ \ \ \ point\ [p.1*c\ -\ p.2*s,\ p.1*s\ +\ p.2*c]}\newline
205
{\tt 20.\ \ }\newline
206
{\tt 21.\ \ bcircle\ t\ ==\ }\newline
207
{\tt 22.\ \ \ \ point\ [3*cos\ t,\ 3*sin\ t,\ 0]}\newline
208
{\tt 23.\ \ \ }\newline
209
{\tt 24.\ \ twist(u,\ t)\ ==}\newline
210
{\tt 25.\ \ \ \ theta\ :=\ 4*t}\newline
211
{\tt 26.\ \ \ \ p\ :=\ point\ [sin\ u,\ cos(u)/2]}\newline
212
{\tt 27.\ \ \ \ rotateBy(p,\ theta)}\newline
213
{\tt 28.\ \ \ }\newline
214
{\tt 29.\ \ ntubeDrawOpt(bcircle,\ twist,\ 0..2*\%pi,\ 0..2*\%pi,}\newline
215
{\tt 30.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ var1Steps\ ==\ 70,\ var2Steps\ ==\ 250)}\newline
216
{\tt 31.\ \ }\newline
217
{\tt 32.\ \ twist2(u,\ t)\ ==}\newline
218
{\tt 33.\ \ \ \ theta\ :=\ t}\newline
219
{\tt 34.\ \ \ \ p\ :=\ point\ [sin\ u,\ cos(u)]}\newline
220
{\tt 35.\ \ \ \ rotateBy(p,\ theta)}\newline
221
{\tt 36.\ \ }\newline
222
{\tt 37.\ \ cf(u,v)\ ==\ sin(21*u)}\newline
223
{\tt 38.\ \ }\newline
224
{\tt 39.\ \ ntubeDrawOpt(bcircle,\ twist2,\ 0..2*\%pi,\ 0..2*\%pi,}\newline
225
{\tt 40.\ \ \ \ colorFunction\ ==\ cf,\ var1Steps\ ==\ 168,}\newline
226
{\tt 41.\ \ \ \ var2Steps\ ==\ 126)}\newline
235
\newcommand{\ugFimagesSixTitle}{images6.input}
236
\newcommand{\ugFimagesSixNumber}{G.5.}
238
% =====================================================================
239
\begin{page}{ugFimagesSixPage}{G.5. images6.input}
240
% =====================================================================
246
{\tt 1.\ \ \ gam(x,y)\ ==\ }\newline
247
{\tt 2.\ \ \ \ \ g\ :=\ Gamma\ complex(x,y)}\newline
248
{\tt 3.\ \ \ \ \ point\ [x,y,max(min(real\ g,\ 4),\ -4),\ argument\ g]}\newline
249
{\tt 4.\ \ \ }\newline
250
{\tt 5.\ \ \ }\newline
251
{\tt 6.\ \ \ draw(gam,\ -\%pi..\%pi,\ -\%pi..\%pi,\ }\newline
252
{\tt 7.\ \ \ \ \ \ \ \ title\ ==\ "Gamma(x\ +\ \%i*y)",\ \_}\newline
253
{\tt 8.\ \ \ \ \ \ \ \ var1Steps\ ==\ 100,\ var2Steps\ ==\ 100)}\newline
254
{\tt 9.\ \ \ }\newline
255
{\tt 10.\ \ b(x,y)\ ==\ Beta(x,y)}\newline
256
{\tt 11.\ \ }\newline
257
{\tt 12.\ \ draw(b,\ -3.1..3,\ -3.1\ ..\ 3,\ title\ ==\ "Beta(x,y)")}\newline
258
{\tt 13.\ \ }\newline
259
{\tt 14.\ \ atf(x,y)\ ==\ }\newline
260
{\tt 15.\ \ \ \ a\ :=\ atan\ complex(x,y)}\newline
261
{\tt 16.\ \ \ \ point\ [x,y,real\ a,\ argument\ a]}\newline
262
{\tt 17.\ \ }\newline
263
{\tt 18.\ \ draw(atf,\ -3.0..\%pi,\ -3.0..\%pi)}\newline
266
%-% \HDindex{function!Gamma}{ugFimagesSixPage}{G.5.}{images6.input}
267
%-% \HDindex{function!Euler Beta}{ugFimagesSixPage}{G.5.}{images6.input}
268
%-% \HDindex{Euler!Beta function}{ugFimagesSixPage}{G.5.}{images6.input}
276
\newcommand{\ugFimagesSevenTitle}{images7.input}
277
\newcommand{\ugFimagesSevenNumber}{G.6.}
279
% =====================================================================
280
\begin{page}{ugFimagesSevenPage}{G.6. images7.input}
281
% =====================================================================
284
First we look at the conformal
285
%-% \HDindex{conformal map}{ugFimagesSevenPage}{G.6.}{images7.input}
286
map \texht{$z \mapsto z + 1/z$}{z +-> z + 1/z}.
290
{\tt 1.\ \ \ )read\ conformal}\newline
291
{\tt 2.\ \ \ }\newline
292
{\tt 3.\ \ \ }\newline
293
{\tt 4.\ \ \ f\ z\ ==\ z}\newline
294
{\tt 5.\ \ \ }\newline
295
{\tt 6.\ \ \ conformalDraw(f,\ -2..2,\ -2..2,\ 9,\ 9,\ "cartesian")}\newline
296
{\tt 7.\ \ \ }\newline
297
{\tt 8.\ \ \ f\ z\ ==\ z\ +\ 1/z}\newline
298
{\tt 9.\ \ \ \ }\newline
299
{\tt 10.\ \ conformalDraw(f,\ -2..2,\ -2..2,\ 9,\ 9,\ "cartesian")}\newline
303
The map \texht{$z \mapsto -(z+1)/(z-1)$}{z +-> -(z+1)/(z-1)} maps
304
the unit disk to the right half-plane, as shown
305
%-% \HDindex{Riemann!sphere}{ugFimagesSevenPage}{G.6.}{images7.input}
306
on the Riemann sphere.
310
{\tt 1.\ \ \ f\ z\ ==\ z}\newline
311
{\tt 2.\ \ \ }\newline
312
{\tt 3.\ \ \ riemannConformalDraw(f,0.1..0.99,0..2*\%pi,7,11,"polar")}\newline
313
{\tt 4.\ \ \ }\newline
314
{\tt 5.\ \ \ f\ z\ ==\ -(z+1)/(z-1)}\newline
315
{\tt 6.\ \ \ }\newline
316
{\tt 7.\ \ \ riemannConformalDraw(f,0.1..0.99,0..2*\%pi,7,11,"polar")}\newline
317
{\tt 8.\ \ \ }\newline
318
{\tt 9.\ \ \ riemannSphereDraw(-4..4,\ -4..4,\ 7,\ 7,\ "cartesian")}\newline
327
\newcommand{\ugFimagesEightTitle}{images8.input}
328
\newcommand{\ugFimagesEightNumber}{G.7.}
330
% =====================================================================
331
\begin{page}{ugFimagesEightPage}{G.7. images8.input}
332
% =====================================================================
338
{\tt 1.\ \ \ )read\ dhtri}\newline
339
{\tt 2.\ \ \ )read\ tetra}\newline
340
{\tt 3.\ \ \ drawPyramid\ 4}\newline
341
{\tt 4.\ \ \ }\newline
342
%-% \HDindex{Sierpinsky's Tetrahedron}{ugFimagesEightPage}{G.7.}{images8.input}
343
{\tt 5.\ \ \ )read\ antoine}\newline
344
{\tt 6.\ \ \ drawRings\ 2}\newline
345
{\tt 7.\ \ \ }\newline
346
%-% \HDindex{Antoine's Necklace}{ugFimagesEightPage}{G.7.}{images8.input}
347
{\tt 8.\ \ \ )read\ scherk}\newline
348
{\tt 9.\ \ \ drawScherk(3,3)}\newline
349
{\tt 10.\ \ }\newline
350
%-% \HDindex{Scherk's minimal surface}{ugFimagesEightPage}{G.7.}{images8.input}
351
{\tt 11.\ \ )read\ ribbonsNew}\newline
352
{\tt 12.\ \ drawRibbons([x**i\ for\ i\ in\ 1..5],\ x=-1..1,\ y=0..2)}\newline
357
%\input{gallery/conformal.htex}
363
\newcommand{\ugFconformalTitle}{conformal.input}
364
\newcommand{\ugFconformalNumber}{G.8.}
366
% =====================================================================
367
\begin{page}{ugFconformalPage}{G.8. conformal.input}
368
% =====================================================================
371
The functions in this section draw conformal maps both on the
372
%-% \HDindex{conformal map}{ugFconformalPage}{G.8.}{conformal.input}
373
plane and on the Riemann sphere.
374
%-% \HDindex{Riemann!sphere}{ugFconformalPage}{G.8.}{conformal.input}
376
%-- Compile, don't interpret functions.
377
%\xmpLine{)set fun comp on}{}
380
{\tt 1.\ \ \ C\ :=\ Complex\ DoubleFloat}\newline
381
{\tt 2.\ \ \ S\ :=\ Segment\ DoubleFloat}\newline
382
{\tt 3.\ \ \ R3\ :=\ Point\ DFLOAT}\newline
383
{\tt 4.\ \ \ \ }\newline
387
\userfun{conformalDraw}{\it (f, rRange, tRange, rSteps, tSteps, coord)}
388
draws the image of the coordinate grid under {\it f} in the complex plane.
389
The grid may be given in either polar or Cartesian coordinates.
390
Argument {\it f} is the function to draw;
391
{\it rRange} is the range of the radius (in polar) or real (in Cartesian);
392
{\it tRange} is the range of \texht{$\theta$}{\theta} (in polar) or imaginary (in Cartesian);
393
{\it tSteps, rSteps}, are the number of intervals in the {\it r} and
394
\texht{$\theta$}{\theta} directions; and
395
{\it coord} is the coordinate system to use (either {\tt "polar"} or
400
{\tt 1.\ \ \ conformalDraw:\ (C\ ->\ C,\ S,\ S,\ PI,\ PI,\ String)\ ->\ VIEW3D}\newline
401
{\tt 2.\ \ \ conformalDraw(f,rRange,tRange,rSteps,tSteps,coord)\ ==}\newline
402
{\tt 3.\ \ \ \ \ transformC\ :=}\newline
403
{\tt 4.\ \ \ \ \ \ \ coord\ =\ "polar"\ =>\ polar2Complex}\newline
404
{\tt 5.\ \ \ \ \ \ \ cartesian2Complex}\newline
405
{\tt 6.\ \ \ \ \ cm\ :=\ makeConformalMap(f,\ transformC)}\newline
406
{\tt 7.\ \ \ \ \ sp\ :=\ createThreeSpace()}\newline
407
{\tt 8.\ \ \ \ \ adaptGrid(sp,\ cm,\ rRange,\ tRange,\ rSteps,\ tSteps)}\newline
408
{\tt 9.\ \ \ \ \ makeViewport3D(sp,\ "Conformal\ Map")}\newline
412
\userfun{riemannConformalDraw}{\it (f, rRange, tRange, rSteps, tSteps, coord)}
413
draws the image of the coordinate grid under {\it f} on the Riemann sphere.
414
The grid may be given in either polar or Cartesian coordinates.
415
Its arguments are the same as those for \userfun{conformalDraw}.
418
{\tt 10.\ \ riemannConformalDraw:(C->C,S,S,PI,PI,String)->VIEW3D}\newline
419
{\tt 11.\ \ riemannConformalDraw(f,\ rRange,\ tRange,}\newline
420
{\tt 12.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rSteps,\ tSteps,\ coord)\ ==}\newline
421
{\tt 13.\ \ \ \ transformC\ :=}\newline
422
{\tt 14.\ \ \ \ \ \ coord\ =\ "polar"\ =>\ polar2Complex}\newline
423
{\tt 15.\ \ \ \ \ \ cartesian2Complex}\newline
424
{\tt 16.\ \ \ \ sp\ :=\ createThreeSpace()}\newline
425
{\tt 17.\ \ \ \ cm\ :=\ makeRiemannConformalMap(f,\ transformC)}\newline
426
{\tt 18.\ \ \ \ adaptGrid(sp,\ cm,\ rRange,\ tRange,\ rSteps,\ tSteps)}\newline
427
{\tt 19.\ \ \ \ curve(sp,[point\ [0,0,2.0@DFLOAT,0],point\ [0,0,2.0@DFLOAT,0]])}\newline
428
{\tt 20.\ \ \ \ makeViewport3D(sp,"Map\ on\ the\ Riemann\ Sphere")}\newline
429
{\tt 21.\ \ }\newline
430
{\tt 22.\ \ adaptGrid(sp,\ f,\ uRange,\ vRange,\ \ uSteps,\ vSteps)\ ==}\newline
431
{\tt 23.\ \ \ \ delU\ :=\ (hi(uRange)\ -\ lo(uRange))/uSteps}\newline
432
{\tt 24.\ \ \ \ delV\ :=\ (hi(vRange)\ -\ lo(vRange))/vSteps}\newline
433
{\tt 25.\ \ \ \ uSteps\ :=\ uSteps\ +\ 1;\ vSteps\ :=\ vSteps\ +\ 1}\newline
434
{\tt 26.\ \ \ \ u\ :=\ lo\ uRange}\newline
435
{\tt 27.\ \ \ \ for\ i\ in\ 1..uSteps\ repeat}\newline
436
{\tt 28.\ \ \ \ \ \ c\ :=\ curryLeft(f,u)}\newline
437
{\tt 29.\ \ \ \ \ \ cf\ :=\ (t:DFLOAT):DFLOAT\ +->\ 0}\newline
438
{\tt 30.\ \ \ \ \ \ makeObject(c,vRange::SEG\ Float,colorFunction==cf,}\newline
439
{\tt 31.\ \ \ \ \ \ \ \ space\ ==\ sp,\ tubeRadius\ ==\ .02,\ tubePoints\ ==\ 6)}\newline
440
{\tt 32.\ \ \ \ \ \ u\ :=\ u\ +\ delU}\newline
441
{\tt 33.\ \ \ \ v\ :=\ lo\ vRange}\newline
442
{\tt 34.\ \ \ \ for\ i\ in\ 1..vSteps\ repeat}\newline
443
{\tt 35.\ \ \ \ \ \ c\ :=\ curryRight(f,v)}\newline
444
{\tt 36.\ \ \ \ \ \ cf\ :=\ (t:DFLOAT):DFLOAT\ +->\ 1}\newline
445
{\tt 37.\ \ \ \ \ \ makeObject(c,uRange::SEG\ Float,colorFunction==cf,}\newline
446
{\tt 38.\ \ \ \ \ \ \ \ space\ ==\ sp,\ tubeRadius\ ==\ .02,\ tubePoints\ ==\ 6)}\newline
447
{\tt 39.\ \ \ \ \ \ v\ :=\ v\ +\ delV}\newline
448
{\tt 40.\ \ \ \ void()}\newline
449
{\tt 41.\ \ }\newline
450
{\tt 42.\ \ riemannTransform(z)\ ==}\newline
451
{\tt 43.\ \ \ \ r\ :=\ sqrt\ norm\ z}\newline
452
{\tt 44.\ \ \ \ cosTheta\ :=\ (real\ z)/r}\newline
453
{\tt 45.\ \ \ \ sinTheta\ :=\ (imag\ z)/r}\newline
454
{\tt 46.\ \ \ \ cp\ :=\ 4*r/(4+r**2)}\newline
455
{\tt 47.\ \ \ \ sp\ :=\ sqrt(1-cp*cp)}\newline
456
{\tt 48.\ \ \ \ if\ r>2\ then\ sp\ :=\ -sp}\newline
457
{\tt 49.\ \ \ \ point\ [cosTheta*cp,\ sinTheta*cp,\ -sp\ +\ 1]}\newline
458
{\tt 50.\ \ \ }\newline
459
{\tt 51.\ \ cartesian2Complex(r:DFLOAT,\ i:DFLOAT):C\ ==}\newline
460
{\tt 52.\ \ \ \ complex(r,\ i)}\newline
461
{\tt 53.\ \ }\newline
462
{\tt 54.\ \ polar2Complex(r:DFLOAT,\ th:DFLOAT):C\ ==\ }\newline
463
{\tt 55.\ \ \ \ complex(r*cos(th),\ r*sin(th))}\newline
464
{\tt 56.\ \ }\newline
465
{\tt 57.\ \ makeConformalMap(f,\ transformC)\ ==}\newline
466
{\tt 58.\ \ \ \ (u:DFLOAT,v:DFLOAT):R3\ +->\ }\newline
467
{\tt 59.\ \ \ \ \ \ z\ :=\ f\ transformC(u,\ v)}\newline
468
{\tt 60.\ \ \ \ \ \ point\ [real\ z,\ imag\ z,\ 0.0@DFLOAT]}\newline
469
{\tt 61.\ \ \ }\newline
470
{\tt 62.\ \ makeRiemannConformalMap(f,\ transformC)\ ==}\newline
471
{\tt 63.\ \ \ \ (u:DFLOAT,\ v:DFLOAT):R3\ +->}\newline
472
{\tt 64.\ \ \ \ \ \ riemannTransform\ f\ transformC(u,\ v)}\newline
473
{\tt 65.\ \ }\newline
474
{\tt 66.\ \ riemannSphereDraw:\ (S,\ S,\ PI,\ PI,\ String)\ ->\ VIEW3D}\newline
475
{\tt 67.\ \ riemannSphereDraw(rRange,tRange,rSteps,tSteps,coord)\ ==}\newline
476
{\tt 68.\ \ \ \ transformC\ :=}\newline
477
{\tt 69.\ \ \ \ \ \ coord\ =\ "polar"\ =>\ polar2Complex}\newline
478
{\tt 70.\ \ \ \ \ \ cartesian2Complex}\newline
479
{\tt 71.\ \ \ \ grid\ :=\ (u:DFLOAT,\ v:DFLOAT):\ R3\ +->\ }\newline
480
{\tt 72.\ \ \ \ \ \ z1\ :=\ transformC(u,\ v)}\newline
481
{\tt 73.\ \ \ \ \ \ point\ [real\ z1,\ imag\ z1,\ 0]}\newline
482
{\tt 74.\ \ \ \ sp\ :=\ createThreeSpace()}\newline
483
{\tt 75.\ \ \ \ adaptGrid(sp,\ grid,\ rRange,\ tRange,\ rSteps,\ tSteps)}\newline
484
{\tt 76.\ \ \ \ connectingLines(sp,grid,rRange,tRange,rSteps,tSteps)}\newline
485
{\tt 77.\ \ \ \ makeObject(riemannSphere,0..2*\%pi,0..\%pi,space==sp)}\newline
486
{\tt 78.\ \ \ \ f\ :=\ (z:C):C\ +->\ z}\newline
487
{\tt 79.\ \ \ \ cm\ :=\ makeRiemannConformalMap(f,\ transformC)}\newline
488
{\tt 80.\ \ \ \ adaptGrid(sp,\ cm,\ rRange,\ tRange,\ rSteps,\ tSteps)}\newline
489
{\tt 81.\ \ \ \ makeViewport3D(sp,\ "Riemann\ Sphere")}\newline
490
{\tt 82.\ \ \ }\newline
491
{\tt 83.\ \ connectingLines(sp,f,uRange,vRange,uSteps,vSteps)\ ==}\newline
492
{\tt 84.\ \ \ \ delU\ :=\ (hi(uRange)\ -\ lo(uRange))/uSteps}\newline
493
{\tt 85.\ \ \ \ delV\ :=\ (hi(vRange)\ -\ lo(vRange))/vSteps}\newline
494
{\tt 86.\ \ \ \ uSteps\ :=\ uSteps\ +\ 1;\ vSteps\ :=\ vSteps\ +\ 1}\newline
495
{\tt 87.\ \ \ \ u\ :=\ lo\ uRange}\newline
496
{\tt 88.\ \ \ \ for\ i\ in\ 1..uSteps\ repeat}\newline
497
{\tt 89.\ \ \ \ \ \ v\ :=\ lo\ vRange}\newline
498
{\tt 90.\ \ \ \ \ \ for\ j\ in\ 1..vSteps\ repeat}\newline
499
{\tt 91.\ \ \ \ \ \ \ \ p1\ :=\ f(u,v)}\newline
500
{\tt 92.\ \ \ \ \ \ \ \ p2\ :=\ riemannTransform\ complex(p1.1,\ p1.2)}\newline
501
{\tt 93.\ \ \ \ \ \ \ \ fun\ :=\ lineFromTo(p1,p2)}\newline
502
{\tt 94.\ \ \ \ \ \ \ \ cf\ :=\ (t:DFLOAT):DFLOAT\ +->\ 3}\newline
503
{\tt 95.\ \ \ \ \ \ \ \ makeObject(fun,\ 0..1,space==sp,tubePoints==4,}\newline
504
{\tt 96.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ tubeRadius==0.01,colorFunction==cf)}\newline
505
{\tt 97.\ \ \ \ \ \ \ \ v\ :=\ v\ +\ delV}\newline
506
{\tt 98.\ \ \ \ \ \ u\ :=\ u\ +\ delU}\newline
507
{\tt 99.\ \ \ \ void()}\newline
508
{\tt 100.\ \ }\newline
509
{\tt 101.\ riemannSphere(u,v)\ ==\ }\newline
510
{\tt 102.\ \ \ sv\ :=\ sin(v)}\newline
511
{\tt 103.\ \ \ 0.99@DFLOAT*(point\ [cos(u)*sv,sin(u)*sv,cos(v),0.0@DFLOAT])+}\newline
512
{\tt 104.\ \ \ \ \ point\ [0.0@DFLOAT,\ 0.0@DFLOAT,\ 1.0@DFLOAT,\ 4.0@DFLOAT]}\newline
513
{\tt 105.\ \ }\newline
514
{\tt 106.\ lineFromTo(p1,\ p2)\ ==}\newline
515
{\tt 107.\ \ \ d\ :=\ p2\ -\ p1}\newline
516
{\tt 108.\ \ \ (t:DFLOAT):Point\ DFLOAT\ +->}\newline
517
{\tt 109.\ \ \ \ \ p1\ +\ t*d}\newline
521
%\input{gallery/tknot.htex}
527
\newcommand{\ugFtknotTitle}{tknot.input}
528
\newcommand{\ugFtknotNumber}{G.9.}
530
% =====================================================================
531
\begin{page}{ugFtknotPage}{G.9. tknot.input}
532
% =====================================================================
535
Create a $(p,q)$ torus-knot with radius $r$ around the curve.
536
The formula was derived by Larry Lambe.
540
{\tt 1.\ \ \ )read\ ntube}\newline
541
{\tt 2.\ \ \ torusKnot:\ (DFLOAT,\ DFLOAT,\ DFLOAT,\ PI,\ PI)\ ->\ VIEW3D}\newline
542
{\tt 3.\ \ \ torusKnot(p,\ q\ ,r,\ uSteps,\ tSteps)\ ==}\newline
543
{\tt 4.\ \ \ \ \ knot\ :=\ (t:DFLOAT):Point\ DFLOAT\ +->\ }\newline
544
{\tt 5.\ \ \ \ \ \ \ fac\ :=\ 4/(2.2@DFLOAT-sin(q*t))}\newline
545
{\tt 6.\ \ \ \ \ \ \ fac\ *\ point\ [cos(p*t),\ sin(p*t),\ cos(q*t)]}\newline
546
{\tt 7.\ \ \ \ \ circle\ :=\ (u:DFLOAT,\ t:DFLOAT):\ Point\ DFLOAT\ +->}\newline
547
{\tt 8.\ \ \ \ \ \ \ r\ *\ point\ [cos\ u,\ sin\ u]}\newline
548
{\tt 9.\ \ \ \ \ ntubeDrawOpt(knot,\ circle,\ 0..2*\%pi,\ 0..2*\%pi,}\newline
549
{\tt 10.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ var1Steps\ ==\ uSteps,\ var2Steps\ ==\ tSteps)}\newline
550
{\tt 11.\ \ }\newline
554
%\input{gallery/ntube.htex}
560
\newcommand{\ugFntubeTitle}{ntube.input}
561
\newcommand{\ugFntubeNumber}{G.10.}
563
% =====================================================================
564
\begin{page}{ugFntubePage}{G.10. ntube.input}
565
% =====================================================================
568
The functions in this file create generalized tubes (also known as generalized
570
These functions draw a 2-d curve in the normal
571
planes around a 3-d curve.
575
{\tt 1.\ \ \ R3\ :=\ Point\ DFLOAT}\newline
576
{\tt 2.\ \ \ R2\ :=\ Point\ DFLOAT}\newline
577
{\tt 3.\ \ \ S\ :=\ Segment\ Float}\newline
578
{\tt 4.\ \ \ }\newline
579
{\tt 5.\ \ \ ThreeCurve\ :=\ DFLOAT\ ->\ R3}\newline
580
{\tt 6.\ \ \ TwoCurve\ :=\ (DFLOAT,\ DFLOAT)\ ->\ R2}\newline
581
{\tt 7.\ \ \ Surface\ :=\ (DFLOAT,\ DFLOAT)\ ->\ R3}\newline
582
{\tt 8.\ \ \ }\newline
583
{\tt 9.\ \ \ FrenetFrame\ :=\ }\newline
584
{\tt 10.\ \ \ \ \ Record(value:R3,tangent:R3,normal:R3,binormal:R3)}\newline
585
{\tt 11.\ \ frame:\ FrenetFrame}\newline
586
{\tt 12.\ \ }\newline
590
\userfun{ntubeDraw}{\it (spaceCurve, planeCurve,}
591
$u_0 .. u_1,$ $t_0 .. t_1)$
592
draws {\it planeCurve} in the normal planes of {\it spaceCurve.}
593
The parameter $u_0 .. u_1$ specifies
594
the parameter range for {\it planeCurve}
595
and $t_0 .. t_1$ specifies the parameter range for {\it spaceCurve}.
596
Additionally, the plane curve function takes
597
a second parameter: the current parameter of {\it spaceCurve}.
598
This allows the plane curve to change shape
599
as it goes around the space curve.
600
See \downlink{``\ugFimagesFiveTitle''}{ugFimagesFivePage} in Section \ugFimagesFiveNumber\ignore{ugFimagesFive} for an example of this.
604
{\tt 1.\ \ \ ntubeDraw:\ (ThreeCurve,TwoCurve,S,S)\ ->\ VIEW3D}\newline
605
{\tt 2.\ \ \ ntubeDraw(spaceCurve,planeCurve,uRange,tRange)\ ==}\newline
606
{\tt 3.\ \ \ \ \ ntubeDrawOpt(spaceCurve,\ planeCurve,\ uRange,\ \_}\newline
607
{\tt 4.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ tRange,\ []\$List\ DROPT)}\newline
608
{\tt 5.\ \ \ \ }\newline
609
{\tt 6.\ \ \ ntubeDrawOpt:\ (ThreeCurve,TwoCurve,S,S,List\ DROPT)}\newline
610
{\tt 7.\ \ \ \ \ \ \ ->\ VIEW3D}\newline
611
{\tt 8.\ \ \ ntubeDrawOpt(spaceCurve,planeCurve,uRange,tRange,l)\ ==}\newline
612
{\tt 9.\ \ \ \ \ \ \ \ \ \ \ \ \ }\newline
613
{\tt 10.\ \ \ \ delT:DFLOAT\ :=\ (hi(tRange)\ -\ lo(tRange))/10000}\newline
614
{\tt 11.\ \ \ \ oldT:DFLOAT\ :=\ lo(tRange)\ -\ 1}\newline
615
{\tt 12.\ \ \ \ fun\ :=\ ngeneralTube(spaceCurve,planeCurve,delT,oldT)}\newline
616
{\tt 13.\ \ \ \ draw(fun,\ uRange,\ tRange,\ l)}\newline
617
{\tt 14.\ \ }\newline
621
\userfun{nfrenetFrame}{\it (c, t, delT)}
622
numerically computes the Frenet frame
623
about the curve {\it c} at {\it t}.
624
Parameter {\it delT} is a small number used to
628
{\tt 15.\ \ nfrenetFrame(c,\ t,\ delT)\ ==}\newline
629
{\tt 16.\ \ \ \ f0\ :=\ c(t)}\newline
630
{\tt 17.\ \ \ \ f1\ :=\ c(t+delT)}\newline
631
{\tt 18.\ \ \ \ t0\ :=\ f1\ -\ f0}\newline
632
{\tt 19.\ \ \ \ n0\ :=\ f1\ +\ f0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\newline
633
{\tt 20.\ \ \ \ b\ :=\ cross(t0,\ n0)}\newline
634
{\tt 21.\ \ \ \ n\ :=\ cross(b,t0)}\newline
635
{\tt 22.\ \ \ \ ln\ :=\ length\ n}\newline
636
{\tt 23.\ \ \ \ lb\ :=\ length\ b}\newline
637
{\tt 24.\ \ \ \ ln\ =\ 0\ or\ lb\ =\ 0\ =>}\newline
638
{\tt 25.\ \ \ \ \ \ \ \ error\ "Frenet\ Frame\ not\ well\ defined"}\newline
639
{\tt 26.\ \ \ \ n\ :=\ (1/ln)*n}\newline
640
{\tt 27.\ \ \ \ b\ :=\ (1/lb)*b}\newline
641
{\tt 28.\ \ \ \ [f0,\ t0,\ n,\ b]\$FrenetFrame}\newline
645
\userfun{ngeneralTube}{\it (spaceCurve, planeCurve,}{\it delT, oltT)}
646
creates a function that can be passed to the system axiomFun{draw} command.
647
The function is a parameterized surface for the general tube
648
around {\it spaceCurve}. {\it delT} is a small number used to compute
649
derivatives. {\it oldT} is used to hold the current value of the
650
{\it t} parameter for {\it spaceCurve.} This is an efficiency measure
651
to ensure that frames are only computed once for each value of {\it t}.
654
{\tt 29.\ \ ngeneralTube:\ (ThreeCurve,\ TwoCurve,\ DFLOAT,\ DFLOAT)\ ->\ Surface}\newline
655
{\tt 30.\ \ ngeneralTube(spaceCurve,\ planeCurve,\ delT,\ oldT)\ ==}\newline
656
{\tt 31.\ \ \ \ free\ frame}\newline
657
{\tt 32.\ \ \ \ (v:DFLOAT,\ t:\ DFLOAT):\ R3\ +->}\newline
658
{\tt 33.\ \ \ \ \ \ if\ (t\ \texht{$\sim$}{~}=\ oldT)\ then}\newline
659
{\tt 34.\ \ \ \ \ \ \ \ frame\ :=\ nfrenetFrame(spaceCurve,\ t,\ delT)}\newline
660
{\tt 35.\ \ \ \ \ \ \ \ oldT\ :=\ t}\newline
661
{\tt 36.\ \ \ \ \ \ p\ :=\ planeCurve(v,\ t)}\newline
662
{\tt 37.\ \ \ \ \ \ frame.value\ +\ p.1*frame.normal\ +\ p.2*frame.binormal}\newline
666
%\input{gallery/dhtri.htex}
672
\newcommand{\ugFdhtriTitle}{dhtri.input}
673
\newcommand{\ugFdhtriNumber}{G.11.}
675
% =====================================================================
676
\begin{page}{ugFdhtriPage}{G.11. dhtri.input}
677
% =====================================================================
680
Create affine transformations (DH matrices) that transform
681
a given triangle into another.
685
{\tt 1.\ \ \ tri2tri:\ (List\ Point\ DFLOAT,\ List\ Point\ DFLOAT)\ ->\ DHMATRIX(DFLOAT)}\newline
686
{\tt 2.\ \ \ tri2tri(t1,\ t2)\ ==}\newline
687
{\tt 3.\ \ \ \ \ n1\ :=\ triangleNormal(t1)}\newline
688
{\tt 4.\ \ \ \ \ n2\ :=\ triangleNormal(t2)}\newline
689
{\tt 5.\ \ \ \ \ tet2tet(concat(t1,\ n1),\ concat(t2,\ n2))}\newline
690
{\tt 6.\ \ \ \ }\newline
691
{\tt 7.\ \ \ tet2tet:\ (List\ Point\ DFLOAT,\ List\ Point\ DFLOAT)\ ->\ DHMATRIX(DFLOAT)}\newline
692
{\tt 8.\ \ \ tet2tet(t1,\ t2)\ ==}\newline
693
{\tt 9.\ \ \ \ \ m1\ :=\ makeColumnMatrix\ t1}\newline
694
{\tt 10.\ \ \ \ m2\ :=\ makeColumnMatrix\ t2}\newline
695
{\tt 11.\ \ \ \ m2\ *\ inverse(m1)}\newline
696
{\tt 12.\ \ \ }\newline
697
{\tt 13.\ \ makeColumnMatrix(t)\ ==}\newline
698
{\tt 14.\ \ \ \ m\ :=\ new(4,4,0)\$DHMATRIX(DFLOAT)}\newline
699
{\tt 15.\ \ \ \ for\ x\ in\ t\ for\ i\ in\ 1..repeat}\newline
700
{\tt 16.\ \ \ \ \ \ for\ j\ in\ 1..3\ repeat}\newline
701
{\tt 17.\ \ \ \ \ \ \ \ m(j,i)\ :=\ x.j}\newline
702
{\tt 18.\ \ \ \ \ \ m(4,i)\ :=\ 1}\newline
703
{\tt 19.\ \ \ \ m}\newline
704
{\tt 20.\ \ \ }\newline
705
{\tt 21.\ \ triangleNormal(t)\ ==}\newline
706
{\tt 22.\ \ \ \ a\ :=\ triangleArea\ t}\newline
707
{\tt 23.\ \ \ \ p1\ :=\ t.2\ -\ t.1}\newline
708
{\tt 24.\ \ \ \ p2\ :=\ t.3\ -\ t.2}\newline
709
{\tt 25.\ \ \ \ c\ :=\ cross(p1,\ p2)}\newline
710
{\tt 26.\ \ \ \ len\ :=\ length(c)}\newline
711
{\tt 27.\ \ \ \ len\ =\ 0\ =>\ error\ "degenerate\ triangle!"}\newline
712
{\tt 28.\ \ \ \ c\ :=\ (1/len)*c}\newline
713
{\tt 29.\ \ \ \ t.1\ +\ sqrt(a)\ *\ c}\newline
714
{\tt 30.\ \ \ }\newline
715
{\tt 31.\ \ triangleArea\ t\ ==}\newline
716
{\tt 32.\ \ \ \ a\ :=\ length(t.2\ -\ t.1)}\newline
717
{\tt 33.\ \ \ \ b\ :=\ length(t.3\ -\ t.2)}\newline
718
{\tt 34.\ \ \ \ c\ :=\ length(t.1\ -\ t.3)}\newline
719
{\tt 35.\ \ \ \ s\ :=\ (a+b+c)/2}\newline
720
{\tt 36.\ \ \ \ sqrt(s*(s-a)*(s-b)*(s-c))}\newline
730
\newcommand{\ugFtetraTitle}{tetra.input}
731
\newcommand{\ugFtetraNumber}{G.12.}
733
% =====================================================================
734
\begin{page}{ugFtetraPage}{G.12. tetra.input}
735
% =====================================================================
738
%\input{gallery/tetra.htex}
739
%\outdent{Sierpinsky's Tetrahedron}
745
{\tt 1.\ \ \ )set\ expose\ add\ con\ DenavitHartenbergMatrix}\newline
746
{\tt 2.\ \ \ }\newline
747
{\tt 3.\ \ \ x1:DFLOAT\ :=\ sqrt(2.0@DFLOAT/3.0@DFLOAT)}\newline
748
{\tt 4.\ \ \ x2:DFLOAT\ :=\ sqrt(3.0@DFLOAT)/6}\newline
749
{\tt 5.\ \ \ }\newline
750
{\tt 6.\ \ \ p1\ :=\ point\ [-0.5@DFLOAT,\ -x2,\ 0.0@DFLOAT]}\newline
751
{\tt 7.\ \ \ p2\ :=\ point\ [0.5@DFLOAT,\ -x2,\ 0.0@DFLOAT]}\newline
752
{\tt 8.\ \ \ p3\ :=\ point\ [0.0@DFLOAT,\ 2*x2,\ 0.0@DFLOAT]}\newline
753
{\tt 9.\ \ \ p4\ :=\ point\ [0.0@DFLOAT,\ 0.0@DFLOAT,\ x1]}\newline
754
{\tt 10.\ \ \ }\newline
755
{\tt 11.\ \ baseTriangle\ \ :=\ [p2,\ p1,\ p3]}\newline
756
{\tt 12.\ \ }\newline
757
{\tt 13.\ \ mt\ \ :=\ [0.5@DFLOAT*(p2+p1),\ 0.5@DFLOAT*(p1+p3),\ 0.5@DFLOAT*(p3+p2)]}\newline
758
{\tt 14.\ \ }\newline
759
{\tt 15.\ \ bt1\ :=\ [mt.1,\ p1,\ mt.2]}\newline
760
{\tt 16.\ \ bt2\ :=\ [p2,\ mt.1,\ mt.3]}\newline
761
{\tt 17.\ \ bt3\ :=\ [mt.2,\ p3,\ mt.3]}\newline
762
{\tt 18.\ \ bt4\ :=\ [0.5@DFLOAT*(p2+p4),\ 0.5@DFLOAT*(p1+p4),\ 0.5@DFLOAT*(p3+p4)]}\newline
763
{\tt 19.\ \ }\newline
764
{\tt 20.\ \ tt1\ :=\ tri2tri(baseTriangle,\ bt1)}\newline
765
{\tt 21.\ \ tt2\ :=\ tri2tri(baseTriangle,\ bt2)}\newline
766
{\tt 22.\ \ tt3\ :=\ tri2tri(baseTriangle,\ bt3)}\newline
767
{\tt 23.\ \ tt4\ :=\ tri2tri(baseTriangle,\ bt4)}\newline
768
{\tt 24.\ \ }\newline
769
{\tt 25.\ \ drawPyramid(n)\ ==}\newline
770
{\tt 26.\ \ \ \ s\ :=\ createThreeSpace()}\newline
771
{\tt 27.\ \ \ \ dh\ :=\ rotatex(0.0@DFLOAT)}\newline
772
{\tt 28.\ \ \ \ drawPyramidInner(s,\ n,\ dh)}\newline
773
{\tt 29.\ \ \ \ makeViewport3D(s,\ "Sierpinsky\ Tetrahedron")}\newline
774
{\tt 30.\ \ }\newline
775
{\tt 31.\ \ drawPyramidInner(s,\ n,\ dh)\ ==}\newline
776
{\tt 32.\ \ \ \ n\ =\ 0\ =>\ makeTetrahedron(s,\ dh,\ n)}\newline
777
{\tt 33.\ \ \ \ drawPyramidInner(s,\ n-1,\ dh\ *\ tt1)}\newline
778
{\tt 34.\ \ \ \ drawPyramidInner(s,\ n-1,\ dh\ *\ tt2)}\newline
779
{\tt 35.\ \ \ \ drawPyramidInner(s,\ n-1,\ dh\ *\ tt3)}\newline
780
{\tt 36.\ \ \ \ drawPyramidInner(s,\ n-1,\ dh\ *\ tt4)}\newline
781
{\tt 37.\ \ }\newline
782
{\tt 38.\ \ makeTetrahedron(sp,\ dh,\ color)\ ==}\newline
783
{\tt 39.\ \ \ \ w1\ :=\ dh*p1}\newline
784
{\tt 40.\ \ \ \ w2\ :=\ dh*p2}\newline
785
{\tt 41.\ \ \ \ w3\ :=\ dh*p3}\newline
786
{\tt 42.\ \ \ \ w4\ :=\ dh*p4}\newline
787
{\tt 43.\ \ \ \ polygon(sp,\ [w1,\ w2,\ w4])}\newline
788
{\tt 44.\ \ \ \ polygon(sp,\ [w1,\ w3,\ w4])}\newline
789
{\tt 45.\ \ \ \ polygon(sp,\ [w2,\ w3,\ w4])}\newline
790
{\tt 46.\ \ \ \ void()}\newline
793
%-% \HDindex{Sierpinsky's Tetrahedron}{ugFtetraPage}{G.12.}{tetra.input}
796
%\input{gallery/antoine.htex}
802
\newcommand{\ugFantoineTitle}{antoine.input}
803
\newcommand{\ugFantoineNumber}{G.13.}
805
% =====================================================================
806
\begin{page}{ugFantoinePage}{G.13. antoine.input}
807
% =====================================================================
810
Draw Antoine's Necklace.
811
%-% \HDindex{Antoine's Necklace}{ugFantoinePage}{G.13.}{antoine.input}
812
Thank you to Matthew Grayson at IBM's T.J Watson Research Center for the idea.
816
{\tt 1.\ \ \ )set\ expose\ add\ con\ DenavitHartenbergMatrix}\newline
817
{\tt 2.\ \ \ }\newline
818
{\tt 3.\ \ \ torusRot:\ DHMATRIX(DFLOAT)}\newline
819
{\tt 4.\ \ \ }\newline
820
{\tt 5.\ \ \ }\newline
821
{\tt 6.\ \ \ drawRings(n)\ ==}\newline
822
{\tt 7.\ \ \ \ \ s\ :=\ createThreeSpace()}\newline
823
{\tt 8.\ \ \ \ \ dh:DHMATRIX(DFLOAT)\ :=\ identity()}\newline
824
{\tt 9.\ \ \ \ \ drawRingsInner(s,\ n,\ dh)}\newline
825
{\tt 10.\ \ \ \ makeViewport3D(s,\ "Antoine's\ Necklace")}\newline
826
{\tt 11.\ \ }\newline
830
In order to draw Antoine rings, we take one ring, scale it down to
831
a smaller size, rotate it around its central axis, translate it
832
to the edge of the larger ring and rotate it around the edge to
833
a point corresponding to its count (there are 10 positions around
834
the edge of the larger ring). For each of these new rings we
835
recursively perform the operations, each ring becoming 10 smaller
836
rings. Notice how the \axiomType{DHMATRIX} operations are used to build up
837
the proper matrix composing all these transformations.
841
{\tt 1.\ \ \ drawRingsInner(s,\ n,\ dh)\ ==}\newline
842
{\tt 2.\ \ \ \ \ n\ =\ 0\ =>}\newline
843
{\tt 3.\ \ \ \ \ \ \ drawRing(s,\ dh)}\newline
844
{\tt 4.\ \ \ \ \ \ \ void()}\newline
845
{\tt 5.\ \ \ \ \ t\ :=\ 0.0@DFLOAT}\newline
846
{\tt 6.\ \ \ \ \ p\ :=\ 0.0@DFLOAT}\newline
847
{\tt 7.\ \ \ \ \ tr\ :=\ 1.0@DFLOAT}\newline
848
{\tt 8.\ \ \ \ \ inc\ :=\ 0.1@DFLOAT}\newline
849
{\tt 9.\ \ \ \ \ for\ i\ in\ 1..10\ repeat}\newline
850
{\tt 10.\ \ \ \ \ \ tr\ :=\ tr\ +\ inc}\newline
851
{\tt 11.\ \ \ \ \ \ inc\ :=\ -inc}\newline
852
{\tt 12.\ \ \ \ \ \ dh'\ :=\ dh*rotatez(t)*translate(tr,0.0@DFLOAT,0.0@DFLOAT)*}\newline
853
{\tt 13.\ \ \ \ \ \ \ \ \ \ \ \ \ rotatey(p)*scale(0.35@DFLOAT,\ 0.48@DFLOAT,\ 0.4@DFLOAT)}\newline
854
{\tt 14.\ \ \ \ \ \ drawRingsInner(s,\ n-1,\ dh')}\newline
855
{\tt 15.\ \ \ \ \ \ t\ :=\ t\ +\ 36.0@DFLOAT}\newline
856
{\tt 16.\ \ \ \ \ \ p\ :=\ p\ +\ 90.0@DFLOAT}\newline
857
{\tt 17.\ \ \ \ void()}\newline
858
{\tt 18.\ \ }\newline
859
{\tt 19.\ \ drawRing(s,\ dh)\ ==}\newline
860
{\tt 20.\ \ \ \ free\ torusRot}\newline
861
{\tt 21.\ \ \ \ torusRot\ :=\ dh}\newline
862
{\tt 22.\ \ \ \ makeObject(torus,\ 0..2*\%pi,\ 0..2*\%pi,\ var1Steps\ ==\ 6,}\newline
863
{\tt 23.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ space\ ==\ s,\ var2Steps\ ==\ 15)}\newline
864
{\tt 24.\ \ }\newline
865
{\tt 25.\ \ torus(u\ ,v)\ ==}\newline
866
{\tt 26.\ \ \ \ cu\ :=\ cos(u)/6}\newline
867
{\tt 27.\ \ \ \ torusRot*point\ [(1+cu)*cos(v),(1+cu)*sin(v),(sin\ u)/6]}\newline
871
%\input{gallery/scherk.htex}
877
\newcommand{\ugFscherkTitle}{scherk.input}
878
\newcommand{\ugFscherkNumber}{G.14.}
880
% =====================================================================
881
\begin{page}{ugFscherkPage}{G.14. scherk.input}
882
% =====================================================================
886
Scherk's minimal surface, defined by:
887
%-% \HDindex{Scherk's minimal surface}{ugFscherkPage}{G.14.}{scherk.input}
888
\texht{$e^z \cos(x) = \cos(y)$}{\axiom{exp(z) * cos(x) = cos(y)}}.
889
See: {\it A Comprehensive Introduction to Differential Geometry,} Vol. 3,
890
by Michael Spivak, Publish Or Perish, Berkeley, 1979, pp. 249-252.
894
{\tt 1.\ \ \ (xOffset,\ yOffset):DFLOAT}\newline
895
{\tt 2.\ \ \ \ }\newline
896
{\tt 3.\ \ \ }\newline
897
{\tt 4.\ \ \ drawScherk(m,n)\ ==}\newline
898
{\tt 5.\ \ \ \ \ free\ xOffset,\ yOffset}\newline
899
{\tt 6.\ \ \ \ \ space\ :=\ createThreeSpace()}\newline
900
{\tt 7.\ \ \ \ \ for\ i\ in\ 0..m-1\ repeat}\newline
901
{\tt 8.\ \ \ \ \ \ \ xOffset\ :=\ i*\%pi}\newline
902
{\tt 9.\ \ \ \ \ \ \ for\ j\ in\ 0\ ..\ n-1\ repeat}\newline
903
{\tt 10.\ \ \ \ \ \ \ \ rem(i+j,\ 2)\ =\ 0\ =>\ 'iter}\newline
904
{\tt 11.\ \ \ \ \ \ \ \ yOffset\ :=\ j*\%pi}\newline
905
{\tt 12.\ \ \ \ \ \ \ \ drawOneScherk(space)}\newline
906
{\tt 13.\ \ \ \ makeViewport3D(space,\ "Scherk's\ Minimal\ Surface")}\newline
907
{\tt 14.\ \ }\newline
908
{\tt 15.\ \ scherk1(u,v)\ ==}\newline
909
{\tt 16.\ \ \ \ x\ :=\ cos(u)/exp(v)}\newline
910
{\tt 17.\ \ \ \ point\ [xOffset\ +\ acos(x),\ yOffset\ +\ u,\ v,\ abs(v)]}\newline
911
{\tt 18.\ \ \ }\newline
912
{\tt 19.\ \ scherk2(u,v)\ ==}\newline
913
{\tt 20.\ \ \ \ x\ :=\ cos(u)/exp(v)}\newline
914
{\tt 21.\ \ \ \ point\ [xOffset\ -\ acos(x),\ yOffset\ +\ u,\ v,\ abs(v)]}\newline
915
{\tt 22.\ \ \ }\newline
916
{\tt 23.\ \ scherk3(u,v)\ ==\ }\newline
917
{\tt 24.\ \ \ \ x\ :=\ exp(v)\ *\ cos(u)}\newline
918
{\tt 25.\ \ \ \ point\ [xOffset\ +\ u,\ yOffset\ +\ acos(x),\ v,\ abs(v)]}\newline
919
{\tt 26.\ \ \ }\newline
920
{\tt 27.\ \ scherk4(u,v)\ ==\ }\newline
921
{\tt 28.\ \ \ \ x\ :=\ exp(v)\ *\ cos(u)}\newline
922
{\tt 29.\ \ \ \ point\ [xOffset\ +\ u,\ yOffset\ -\ acos(x),\ v,\ abs(v)]}\newline
923
{\tt 30.\ \ \ }\newline
924
{\tt 31.\ \ drawOneScherk(s)\ ==}\newline
925
{\tt 32.\ \ \ \ makeObject(scherk1,-\%pi/2..\%pi/2,0..\%pi/2,space==s,}\newline
926
{\tt 33.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ var1Steps\ ==\ 28,\ var2Steps\ ==\ 28)}\newline
927
{\tt 34.\ \ \ \ makeObject(scherk2,-\%pi/2..\%pi/2,0..\%pi/2,space==s,}\newline
928
{\tt 35.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ var1Steps\ ==\ 28,\ var2Steps\ ==\ 28)}\newline
929
{\tt 36.\ \ \ \ makeObject(scherk3,-\%pi/2..\%pi/2,-\%pi/2..0,space==s,}\newline
930
{\tt 37.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ var1Steps\ ==\ 28,\ var2Steps\ ==\ 28)}\newline
931
{\tt 38.\ \ \ \ makeObject(scherk4,-\%pi/2..\%pi/2,-\%pi/2..0,space==s,}\newline
932
{\tt 39.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ var1Steps\ ==\ 28,\ var2Steps\ ==\ 28)}\newline
933
{\tt 40.\ \ \ \ void()}\newline