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
4%
5%
6%
7%
8%
9
10%
11\newcommand{\ugAppGraphicsTitle}{Programs for FriCAS Images}
12\newcommand{\ugAppGraphicsNumber}{G.}
13%
14% =====================================================================
15\begin{page}{ugAppGraphicsPage}{G. Programs for FriCAS Images}
16% =====================================================================
17\beginscroll
18%
19This appendix contains the \Language{} programs used to generate
20the images in the \Gallery{} color insert of this book.
21All these input files are included
22with the \Language{} system.
23To produce the images
24on page 6 of the \Gallery{} insert, for example, issue the command:
25\begin{verbatim}
26)read images6
27\end{verbatim}
28
29These images were produced on an IBM RS/6000 model 530 with a
30standard color graphics adapter.  The smooth shaded images
31were made from X Window System screen dumps.
32The remaining images were produced with \Language{}-generated
33PostScript output.  The images were reproduced from slides made on an Agfa
34ChromaScript PostScript interpreter with a Matrix Instruments QCR camera.
35
36\beginmenu
37    \menudownlink{{F.1. images1.input}}{ugFimagesOnePage}
38    \menudownlink{{F.2. images2.input}}{ugFimagesTwoPage}
39    \menudownlink{{F.3. images3.input}}{ugFimagesThreePage}
40    \menudownlink{{F.4. images5.input}}{ugFimagesFivePage}
41    \menudownlink{{F.5. images6.input}}{ugFimagesSixPage}
42    \menudownlink{{F.6. images7.input}}{ugFimagesSevenPage}
43    \menudownlink{{F.7. images8.input}}{ugFimagesEightPage}
44    \menudownlink{{F.8. conformal.input}}{ugFconformalPage}
45    \menudownlink{{F.9. tknot.input}}{ugFtknotPage}
46    \menudownlink{{F.10. ntube.input}}{ugFntubePage}
47    \menudownlink{{F.11. dhtri.input}}{ugFdhtriPage}
48    \menudownlink{{F.12. tetra.input}}{ugFtetraPage}
49    \menudownlink{{F.13. antoine.input}}{ugFantoinePage}
50    \menudownlink{{F.14. scherk.input}}{ugFscherkPage}
51\endmenu
52\endscroll
53\autobuttons
54\end{page}
55%
56%
57\newcommand{\ugFimagesOneTitle}{images1.input}
58\newcommand{\ugFimagesOneNumber}{G.1.}
59%
60% =====================================================================
61\begin{page}{ugFimagesOnePage}{G.1. images1.input}
62% =====================================================================
63\beginscroll
64
65
66\noindent
67{\tt 1.\ \ \ )read\ tknot}\newline
68{\tt 2.\ \ \ }\newline
69{\tt 3.\ \ \ torusKnot(15,17,\ 0.1,\ 6,\ 700)}\newline
70
71\noindent
72%-% \HDindex{torus knot}{ugFimagesOnePage}{G.1.}{images1.input}
73
74\newpage
75\endscroll
76\autobuttons
77\end{page}
78%
79%
80\newcommand{\ugFimagesTwoTitle}{images2.input}
81\newcommand{\ugFimagesTwoNumber}{G.2.}
82%
83% =====================================================================
84\begin{page}{ugFimagesTwoPage}{G.2. images2.input}
85% =====================================================================
86\beginscroll
87
88These images illustrate how Newton's method converges when computing the
89%-% \HDindex{Newton iteration}{ugFimagesTwoPage}{G.2.}{images2.input}
90complex cube roots of 2.   Each point in the \smath{(x,y)}-plane represents the
91complex number \smath{x + iy,} which is given as a starting point for Newton's
92method.  The poles in these images represent bad starting values.
93The flat areas are the regions of convergence to the three roots.
94
95
96\noindent
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
101
102\noindent
103
104The function f^n computes $n$ steps of Newton's method.
105
106
107\noindent
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
112
113\noindent
114
115\endscroll
116\autobuttons
117\end{page}
118%
119%
120\newcommand{\ugFimagesThreeTitle}{images3.input}
121\newcommand{\ugFimagesThreeNumber}{G.3.}
122%
123% =====================================================================
124\begin{page}{ugFimagesThreePage}{G.3. images3.input}
125% =====================================================================
126\beginscroll
127
128
129\noindent
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
132
133\noindent
134
135\endscroll
136\autobuttons
137\end{page}
138%
139%
140\newcommand{\ugFimagesFiveTitle}{images5.input}
141\newcommand{\ugFimagesFiveNumber}{G.4.}
142%
143% =====================================================================
144\begin{page}{ugFimagesFivePage}{G.4. images5.input}
145% =====================================================================
146\beginscroll
147
148The parameterization of the Etruscan Venus is due to George Frances.
149%-% \HDindex{Etruscan Venus}{ugFimagesFivePage}{G.4.}{images5.input}
150
151
152\noindent
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
167
168\noindent
169
170The Figure-8 Klein Bottle
171%-% \HDindex{Klein bottle}{ugFimagesFivePage}{G.4.}{images5.input}
172parameterization is from
173``Differential Geometry and Computer Graphics'' by Thomas Banchoff,
174in {\it Perspectives in Mathematics,} Anniversary of Oberwolfasch 1984,
175Birkh\"{a}user-Verlag, Basel, pp. 43-60.
176
177
178\noindent
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
193
194\noindent
195
196The next two images are examples of generalized tubes.
197
198
199\noindent
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
227
228\noindent
229
230\endscroll
231\autobuttons
232\end{page}
233%
234%
235\newcommand{\ugFimagesSixTitle}{images6.input}
236\newcommand{\ugFimagesSixNumber}{G.5.}
237%
238% =====================================================================
239\begin{page}{ugFimagesSixPage}{G.5. images6.input}
240% =====================================================================
241\beginscroll
242
243
244\noindent
245{\tt 1.\ \ \ gam(x,y)\ ==}\newline
246{\tt 2.\ \ \ \ \ g\ :=\ Gamma\ complex(x,y)}\newline
247{\tt 3.\ \ \ \ \ point\ [x,y,max(min(real\ g,\ 4),\ -4),\ argument\ g]}\newline
248{\tt 4.\ \ \ }\newline
249{\tt 5.\ \ \ }\newline
250{\tt 6.\ \ \ draw(gam,\ -\%pi..\%pi,\ -\%pi..\%pi,}\newline
251{\tt 7.\ \ \ \ \ \ \ \ title\ ==\ "Gamma(x\ +\ \%i*y)",\ \_}\newline
252{\tt 8.\ \ \ \ \ \ \ \ var1Steps\ ==\ 100,\ var2Steps\ ==\ 100)}\newline
253{\tt 9.\ \ \ }\newline
254{\tt 10.\ \ b(x,y)\ ==\ Beta(x,y)}\newline
255{\tt 11.\ \ }\newline
256{\tt 12.\ \ draw(b,\ -3.1..3,\ -3.1\ ..\ 3,\ title\ ==\ "Beta(x,y)")}\newline
257{\tt 13.\ \ }\newline
258{\tt 14.\ \ atf(x,y)\ ==}\newline
259{\tt 15.\ \ \ \ a\ :=\ atan\ complex(x,y)}\newline
260{\tt 16.\ \ \ \ point\ [x,y,real\ a,\ argument\ a]}\newline
261{\tt 17.\ \ }\newline
262{\tt 18.\ \ draw(atf,\ -3.0..\%pi,\ -3.0..\%pi)}\newline
263
264\noindent
265%-% \HDindex{function!Gamma}{ugFimagesSixPage}{G.5.}{images6.input}
266%-% \HDindex{function!Euler Beta}{ugFimagesSixPage}{G.5.}{images6.input}
267%-% \HDindex{Euler!Beta function}{ugFimagesSixPage}{G.5.}{images6.input}
268
269
270\endscroll
271\autobuttons
272\end{page}
273%
274%
275\newcommand{\ugFimagesSevenTitle}{images7.input}
276\newcommand{\ugFimagesSevenNumber}{G.6.}
277%
278% =====================================================================
279\begin{page}{ugFimagesSevenPage}{G.6. images7.input}
280% =====================================================================
281\beginscroll
282
283First we look at the conformal
284%-% \HDindex{conformal map}{ugFimagesSevenPage}{G.6.}{images7.input}
285map z +-> z + 1/z.
286
287
288\noindent
289{\tt 1.\ \ \ )read\ conformal}\newline
290{\tt 2.\ \ \ }\newline
291{\tt 3.\ \ \ }\newline
292{\tt 4.\ \ \ f\ z\ ==\ z}\newline
293{\tt 5.\ \ \ }\newline
294{\tt 6.\ \ \ conformalDraw(f,\ -2..2,\ -2..2,\ 9,\ 9,\ "cartesian")}\newline
295{\tt 7.\ \ \ }\newline
296{\tt 8.\ \ \ f\ z\ ==\ z\ +\ 1/z}\newline
297{\tt 9.\ \ \ }\newline
298{\tt 10.\ \ conformalDraw(f,\ -2..2,\ -2..2,\ 9,\ 9,\ "cartesian")}\newline
299
300\noindent
301
302The map z +-> -(z+1)/(z-1) maps
303the unit disk to the right half-plane, as shown
304%-% \HDindex{Riemann!sphere}{ugFimagesSevenPage}{G.6.}{images7.input}
305on the Riemann sphere.
306
307
308\noindent
309{\tt 1.\ \ \ f\ z\ ==\ z}\newline
310{\tt 2.\ \ \ }\newline
311{\tt 3.\ \ \ riemannConformalDraw(f,0.1..0.99,0..2*\%pi,7,11,"polar")}\newline
312{\tt 4.\ \ \ }\newline
313{\tt 5.\ \ \ f\ z\ ==\ -(z+1)/(z-1)}\newline
314{\tt 6.\ \ \ riemannConformalDraw(f,0.1..0.99,0..2*\%pi,7,11,"polar")}\newline
315{\tt 7.\ \ \ }\newline
316{\tt 8.\ \ \ riemannSphereDraw(-4..4,\ -4..4,\ 7,\ 7,\ "cartesian")}\newline
317
318\noindent
319
320\endscroll
321\autobuttons
322\end{page}
323%
324%
325\newcommand{\ugFimagesEightTitle}{images8.input}
326\newcommand{\ugFimagesEightNumber}{G.7.}
327%
328% =====================================================================
329\begin{page}{ugFimagesEightPage}{G.7. images8.input}
330% =====================================================================
331\beginscroll
332
333
334\noindent
335{\tt 1.\ \ \ )read\ dhtri}\newline
336{\tt 2.\ \ \ )read\ tetra}\newline
337{\tt 3.\ \ \ drawPyramid\ 4}\newline
338{\tt 4.\ \ \ }\newline
339%-% \HDindex{Sierpinsky's Tetrahedron}{ugFimagesEightPage}{G.7.}{images8.input}
340{\tt 5.\ \ \ )read\ antoine}\newline
341{\tt 6.\ \ \ drawRings\ 2}\newline
342{\tt 7.\ \ \ }\newline
343%-% \HDindex{Antoine's Necklace}{ugFimagesEightPage}{G.7.}{images8.input}
344{\tt 8.\ \ \ )read\ scherk}\newline
345{\tt 9.\ \ \ drawScherk(3,3)}\newline
346{\tt 10.\ \ }\newline
347%-% \HDindex{Scherk's minimal surface}{ugFimagesEightPage}{G.7.}{images8.input}
348{\tt 11.\ \ )read\ ribbonsNew}\newline
349{\tt 12.\ \ drawRibbons([x^i\ for\ i\ in\ 1..5],\ x=-1..1,\ y=0..2)}\newline
350
351\noindent
352
353
354%\input{gallery/conformal.htex}
355\endscroll
356\autobuttons
357\end{page}
358%
359%
360\newcommand{\ugFconformalTitle}{conformal.input}
361\newcommand{\ugFconformalNumber}{G.8.}
362%
363% =====================================================================
364\begin{page}{ugFconformalPage}{G.8. conformal.input}
365% =====================================================================
366\beginscroll
367%
368The functions in this section draw conformal maps both on the
369%-% \HDindex{conformal map}{ugFconformalPage}{G.8.}{conformal.input}
370plane and on the Riemann sphere.
371%-% \HDindex{Riemann!sphere}{ugFconformalPage}{G.8.}{conformal.input}
372
373%\xmpLine{)set fun comp on}{}
374
375\noindent
376{\tt 1.\ \ \ C\ :=\ Complex\ DoubleFloat}\newline
377{\tt 2.\ \ \ S\ :=\ Segment\ DoubleFloat}\newline
378{\tt 3.\ \ \ R3\ :=\ Point\ DFLOAT}\newline
379{\tt 4.\ \ \ }\newline
380
381\noindent
382
383\userfun{conformalDraw}{\it (f, rRange, tRange, rSteps, tSteps, coord)}
384draws the image of the coordinate grid under {\it f} in the complex plane.
385The grid may be given in either polar or Cartesian coordinates.
386Argument {\it f} is the function to draw;
387{\it rRange} is the range of the radius (in polar) or real (in Cartesian);
388{\it tRange} is the range of \theta (in polar) or imaginary (in Cartesian);
389{\it tSteps, rSteps}, are the number of intervals in the {\it r} and
390\theta directions; and
391{\it coord} is the coordinate system to use (either {\tt "polar"} or
392{\tt "cartesian"}).
393
394
395\noindent
396{\tt 1.\ \ \ conformalDraw:\ (C\ ->\ C,\ S,\ S,\ PI,\ PI,\ String)\ ->\ VIEW3D}\newline
397{\tt 2.\ \ \ conformalDraw(f,rRange,tRange,rSteps,tSteps,coord)\ ==}\newline
398{\tt 3.\ \ \ \ \ transformC\ :=}\newline
399{\tt 4.\ \ \ \ \ \ \ coord\ =\ "polar"\ =>\ polar2Complex}\newline
400{\tt 5.\ \ \ \ \ \ \ cartesian2Complex}\newline
401{\tt 6.\ \ \ \ \ cm\ :=\ makeConformalMap(f,\ transformC)}\newline
402{\tt 7.\ \ \ \ \ sp\ :=\ createThreeSpace()}\newline
403{\tt 8.\ \ \ \ \ adaptGrid(sp,\ cm,\ rRange,\ tRange,\ rSteps,\ tSteps)}\newline
404{\tt 9.\ \ \ \ \ makeViewport3D(sp,\ "Conformal\ Map")}\newline
405
406\noindent
407
408\userfun{riemannConformalDraw}{\it (f, rRange, tRange, rSteps, tSteps, coord)}
409draws the image of the coordinate grid under {\it f} on the Riemann sphere.
410The grid may be given in either polar or Cartesian coordinates.
411Its arguments are the same as those for \userfun{conformalDraw}.
412
413\noindent
414{\tt 10.\ \ riemannConformalDraw:(C->C,S,S,PI,PI,String)->VIEW3D}\newline
415{\tt 11.\ \ riemannConformalDraw(f,\ rRange,\ tRange,}\newline
416{\tt 12.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rSteps,\ tSteps,\ coord)\ ==}\newline
417{\tt 13.\ \ \ \ transformC\ :=}\newline
418{\tt 14.\ \ \ \ \ \ coord\ =\ "polar"\ =>\ polar2Complex}\newline
419{\tt 15.\ \ \ \ \ \ cartesian2Complex}\newline
420{\tt 16.\ \ \ \ sp\ :=\ createThreeSpace()}\newline
421{\tt 17.\ \ \ \ cm\ :=\ makeRiemannConformalMap(f,\ transformC)}\newline
422{\tt 18.\ \ \ \ adaptGrid(sp,\ cm,\ rRange,\ tRange,\ rSteps,\ tSteps)}\newline
423{\tt 19.\ \ \ \ curve(sp,[point\ [0,0,2.0@DFLOAT,0],point\ [0,0,2.0@DFLOAT,0]])}\newline
424{\tt 20.\ \ \ \ makeViewport3D(sp,"Map\ on\ the\ Riemann\ Sphere")}\newline
425{\tt 21.\ \ }\newline
426{\tt 22.\ \ adaptGrid(sp,\ f,\ uRange,\ vRange,\ \ uSteps,\ vSteps)\ ==}\newline
427{\tt 23.\ \ \ \ delU\ :=\ (high(uRange)\ -\ low(uRange))/uSteps}\newline
428{\tt 24.\ \ \ \ delV\ :=\ (high(vRange)\ -\ low(vRange))/vSteps}\newline
429{\tt 25.\ \ \ \ uSteps\ :=\ uSteps\ +\ 1;\ vSteps\ :=\ vSteps\ +\ 1}\newline
430{\tt 26.\ \ \ \ u\ :=\ low\ uRange}\newline
431{\tt 27.\ \ \ \ for\ i\ in\ 1..uSteps\ repeat}\newline
432{\tt 28.\ \ \ \ \ \ c\ :=\ curryLeft(f,u)}\newline
433{\tt 29.\ \ \ \ \ \ cf\ :=\ (t:DFLOAT):DFLOAT\ +->\ 0}\newline
434{\tt 30.\ \ \ \ \ \ makeObject(c,vRange::SEG\ Float,colorFunction==cf,}\newline
435{\tt 31.\ \ \ \ \ \ \ \ space\ ==\ sp,\ tubeRadius\ ==\ .02,\ tubePoints\ ==\ 6)}\newline
436{\tt 32.\ \ \ \ \ \ u\ :=\ u\ +\ delU}\newline
437{\tt 33.\ \ \ \ v\ :=\ low\ vRange}\newline
438{\tt 34.\ \ \ \ for\ i\ in\ 1..vSteps\ repeat}\newline
439{\tt 35.\ \ \ \ \ \ c\ :=\ curryRight(f,v)}\newline
440{\tt 36.\ \ \ \ \ \ cf\ :=\ (t:DFLOAT):DFLOAT\ +->\ 1}\newline
441{\tt 37.\ \ \ \ \ \ makeObject(c,uRange::SEG\ Float,colorFunction==cf,}\newline
442{\tt 38.\ \ \ \ \ \ \ \ space\ ==\ sp,\ tubeRadius\ ==\ .02,\ tubePoints\ ==\ 6)}\newline
443{\tt 39.\ \ \ \ \ \ v\ :=\ v\ +\ delV}\newline
444{\tt 40.\ \ \ \ void()}\newline
445{\tt 41.\ \ }\newline
446{\tt 42.\ \ riemannTransform(z)\ ==}\newline
447{\tt 43.\ \ \ \ r\ :=\ sqrt\ norm\ z}\newline
448{\tt 44.\ \ \ \ cosTheta\ :=\ (real\ z)/r}\newline
449{\tt 45.\ \ \ \ sinTheta\ :=\ (imag\ z)/r}\newline
450{\tt 46.\ \ \ \ cp\ :=\ 4*r/(4+r^2)}\newline
451{\tt 47.\ \ \ \ sp\ :=\ sqrt(1-cp*cp)}\newline
452{\tt 48.\ \ \ \ if\ r>2\ then\ sp\ :=\ -sp}\newline
453{\tt 49.\ \ \ \ point\ [cosTheta*cp,\ sinTheta*cp,\ -sp\ +\ 1]}\newline
454{\tt 50.\ \ }\newline
455{\tt 51.\ \ cartesian2Complex(r:DFLOAT,\ i:DFLOAT):C\ ==}\newline
456{\tt 52.\ \ \ \ complex(r,\ i)}\newline
457{\tt 53.\ \ }\newline
458{\tt 54.\ \ polar2Complex(r:DFLOAT,\ th:DFLOAT):C\ ==}\newline
459{\tt 55.\ \ \ \ complex(r*cos(th),\ r*sin(th))}\newline
460{\tt 56.\ \ }\newline
461{\tt 57.\ \ makeConformalMap(f,\ transformC)\ ==}\newline
462{\tt 58.\ \ \ \ (u:DFLOAT,v:DFLOAT):R3\ +->}\newline
463{\tt 59.\ \ \ \ \ \ z\ :=\ f\ transformC(u,\ v)}\newline
464{\tt 60.\ \ \ \ \ \ point\ [real\ z,\ imag\ z,\ 0.0@DFLOAT]}\newline
465{\tt 61.\ \ }\newline
466{\tt 62.\ \ makeRiemannConformalMap(f,\ transformC)\ ==}\newline
467{\tt 63.\ \ \ \ (u:DFLOAT,\ v:DFLOAT):R3\ +->}\newline
468{\tt 64.\ \ \ \ \ \ riemannTransform\ f\ transformC(u,\ v)}\newline
469{\tt 65.\ \ }\newline
470{\tt 66.\ \ riemannSphereDraw:\ (S,\ S,\ PI,\ PI,\ String)\ ->\ VIEW3D}\newline
471{\tt 67.\ \ riemannSphereDraw(rRange,tRange,rSteps,tSteps,coord)\ ==}\newline
472{\tt 68.\ \ \ \ transformC\ :=}\newline
473{\tt 69.\ \ \ \ \ \ coord\ =\ "polar"\ =>\ polar2Complex}\newline
474{\tt 70.\ \ \ \ \ \ cartesian2Complex}\newline
475{\tt 71.\ \ \ \ grid\ :=\ (u:DFLOAT,\ v:DFLOAT):\ R3\ +->}\newline
476{\tt 72.\ \ \ \ \ \ z1\ :=\ transformC(u,\ v)}\newline
477{\tt 73.\ \ \ \ \ \ point\ [real\ z1,\ imag\ z1,\ 0]}\newline
478{\tt 74.\ \ \ \ sp\ :=\ createThreeSpace()}\newline
479{\tt 75.\ \ \ \ adaptGrid(sp,\ grid,\ rRange,\ tRange,\ rSteps,\ tSteps)}\newline
480{\tt 76.\ \ \ \ connectingLines(sp,grid,rRange,tRange,rSteps,tSteps)}\newline
481{\tt 77.\ \ \ \ makeObject(riemannSphere,0..2*\%pi,0..\%pi,space==sp)}\newline
482{\tt 78.\ \ \ \ f\ :=\ (z:C):C\ +->\ z}\newline
483{\tt 79.\ \ \ \ cm\ :=\ makeRiemannConformalMap(f,\ transformC)}\newline
484{\tt 80.\ \ \ \ adaptGrid(sp,\ cm,\ rRange,\ tRange,\ rSteps,\ tSteps)}\newline
485{\tt 81.\ \ \ \ makeViewport3D(sp,\ "Riemann\ Sphere")}\newline
486{\tt 82.\ \ }\newline
487{\tt 83.\ \ connectingLines(sp,f,uRange,vRange,uSteps,vSteps)\ ==}\newline
488{\tt 84.\ \ \ \ delU\ :=\ (high(uRange)\ -\ low(uRange))/uSteps}\newline
489{\tt 85.\ \ \ \ delV\ :=\ (high(vRange)\ -\ low(vRange))/vSteps}\newline
490{\tt 86.\ \ \ \ uSteps\ :=\ uSteps\ +\ 1;\ vSteps\ :=\ vSteps\ +\ 1}\newline
491{\tt 87.\ \ \ \ u\ :=\ low\ uRange}\newline
492{\tt 88.\ \ \ \ for\ i\ in\ 1..uSteps\ repeat}\newline
493{\tt 89.\ \ \ \ \ \ v\ :=\ low\ vRange}\newline
494{\tt 90.\ \ \ \ \ \ for\ j\ in\ 1..vSteps\ repeat}\newline
495{\tt 91.\ \ \ \ \ \ \ \ p1\ :=\ f(u,v)}\newline
496{\tt 92.\ \ \ \ \ \ \ \ p2\ :=\ riemannTransform\ complex(p1.1,\ p1.2)}\newline
497{\tt 93.\ \ \ \ \ \ \ \ fun\ :=\ lineFromTo(p1,p2)}\newline
498{\tt 94.\ \ \ \ \ \ \ \ cf\ :=\ (t:DFLOAT):DFLOAT\ +->\ 3}\newline
499{\tt 95.\ \ \ \ \ \ \ \ makeObject(fun,\ 0..1,space==sp,tubePoints==4,}\newline
500{\tt 96.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ tubeRadius==0.01,colorFunction==cf)}\newline
501{\tt 97.\ \ \ \ \ \ \ \ v\ :=\ v\ +\ delV}\newline
502{\tt 98.\ \ \ \ \ \ u\ :=\ u\ +\ delU}\newline
503{\tt 99.\ \ \ \ void()}\newline
504{\tt 100.\ }\newline
505{\tt 101.\ riemannSphere(u,v)\ ==}\newline
506{\tt 102.\ \ \ sv\ :=\ sin(v)}\newline
507{\tt 103.\ \ \ 0.99@DFLOAT*(point\ [cos(u)*sv,sin(u)*sv,cos(v),0.0@DFLOAT])+}\newline
508{\tt 104.\ \ \ \ \ point\ [0.0@DFLOAT,\ 0.0@DFLOAT,\ 1.0@DFLOAT,\ 4.0@DFLOAT]}\newline
509{\tt 105.\ }\newline
510{\tt 106.\ lineFromTo(p1,\ p2)\ ==}\newline
511{\tt 107.\ \ \ d\ :=\ p2\ -\ p1}\newline
512{\tt 108.\ \ \ (t:DFLOAT):Point\ DFLOAT\ +->}\newline
513{\tt 109.\ \ \ \ \ p1\ +\ t*d}\newline
514
515\noindent
516
517%\input{gallery/tknot.htex}
518\endscroll
519\autobuttons
520\end{page}
521%
522%
523\newcommand{\ugFtknotTitle}{tknot.input}
524\newcommand{\ugFtknotNumber}{G.9.}
525%
526% =====================================================================
527\begin{page}{ugFtknotPage}{G.9. tknot.input}
528% =====================================================================
529\beginscroll
530%
531Create a $(p,q)$ torus-knot with radius $r$ around the curve.
532The formula was derived by Larry Lambe.
533
534
535\noindent
536{\tt 1.\ \ \ )read\ ntube}\newline
537{\tt 2.\ \ \ torusKnot:\ (DFLOAT,\ DFLOAT,\ DFLOAT,\ PI,\ PI)\ ->\ VIEW3D}\newline
538{\tt 3.\ \ \ torusKnot(p,\ q\ ,r,\ uSteps,\ tSteps)\ ==}\newline
539{\tt 4.\ \ \ \ \ knot\ :=\ (t:DFLOAT):Point\ DFLOAT\ +->}\newline
540{\tt 5.\ \ \ \ \ \ \ fac\ :=\ 4/(2.2@DFLOAT-sin(q*t))}\newline
541{\tt 6.\ \ \ \ \ \ \ fac\ *\ point\ [cos(p*t),\ sin(p*t),\ cos(q*t)]}\newline
542{\tt 7.\ \ \ \ \ circle\ :=\ (u:DFLOAT,\ t:DFLOAT):\ Point\ DFLOAT\ +->}\newline
543{\tt 8.\ \ \ \ \ \ \ r\ *\ point\ [cos\ u,\ sin\ u]}\newline
544{\tt 9.\ \ \ \ \ ntubeDrawOpt(knot,\ circle,\ 0..2*\%pi,\ 0..2*\%pi,}\newline
545{\tt 10.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ var1Steps\ ==\ uSteps,\ var2Steps\ ==\ tSteps)}\newline
546{\tt 11.\ \ }\newline
547
548\noindent
549
550%\input{gallery/ntube.htex}
551\endscroll
552\autobuttons
553\end{page}
554%
555%
556\newcommand{\ugFntubeTitle}{ntube.input}
557\newcommand{\ugFntubeNumber}{G.10.}
558%
559% =====================================================================
560\begin{page}{ugFntubePage}{G.10. ntube.input}
561% =====================================================================
562\beginscroll
563%
564The functions in this file create generalized tubes (also known as generalized
565cylinders).
566These functions draw a 2-d curve in the normal
567planes around a 3-d curve.
568
569
570\noindent
571{\tt 1.\ \ \ R3\ :=\ Point\ DFLOAT}\newline
572{\tt 2.\ \ \ R2\ :=\ Point\ DFLOAT}\newline
573{\tt 3.\ \ \ S\ :=\ Segment\ Float}\newline
574{\tt 4.\ \ \ }\newline
575{\tt 5.\ \ \ ThreeCurve\ :=\ DFLOAT\ ->\ R3}\newline
576{\tt 6.\ \ \ TwoCurve\ :=\ (DFLOAT,\ DFLOAT)\ ->\ R2}\newline
577{\tt 7.\ \ \ Surface\ :=\ (DFLOAT,\ DFLOAT)\ ->\ R3}\newline
578{\tt 8.\ \ \ }\newline
579{\tt 9.\ \ \ FrenetFrame\ :=}\newline
580{\tt 10.\ \ \ \ \ Record(value:R3,tangent:R3,normal:R3,binormal:R3)}\newline
581{\tt 11.\ \ frame:\ FrenetFrame}\newline
582{\tt 12.\ \ }\newline
583
584\noindent
585
586\userfun{ntubeDraw}{\it (spaceCurve, planeCurve,}
587$u_0 .. u_1,$ $t_0 .. t_1)$
588draws {\it planeCurve} in the normal planes of {\it spaceCurve.}
589The parameter $u_0 .. u_1$ specifies
590the parameter range for {\it planeCurve}
591and $t_0 .. t_1$ specifies the parameter range for {\it spaceCurve}.
592Additionally, the plane curve function takes
593a second parameter: the current parameter of {\it spaceCurve}.
594This allows the plane curve to change shape
595as it goes around the space curve.
596See \downlink{``\ugFimagesFiveTitle''}{ugFimagesFivePage} in Section \ugFimagesFiveNumber\ignore{ugFimagesFive} for an example of this.
597%
598
599\noindent
600{\tt 1.\ \ \ ntubeDraw:\ (ThreeCurve,TwoCurve,S,S)\ ->\ VIEW3D}\newline
601{\tt 2.\ \ \ ntubeDraw(spaceCurve,planeCurve,uRange,tRange)\ ==}\newline
602{\tt 3.\ \ \ \ \ ntubeDrawOpt(spaceCurve,\ planeCurve,\ uRange,\ \_}\newline
603{\tt 4.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ tRange,\ []\$List\ DROPT)}\newline
604{\tt 5.\ \ \ }\newline
605{\tt 6.\ \ \ ntubeDrawOpt:\ (ThreeCurve,TwoCurve,S,S,List\ DROPT)}\newline
606{\tt 7.\ \ \ \ \ \ \ ->\ VIEW3D}\newline
607{\tt 8.\ \ \ ntubeDrawOpt(spaceCurve,planeCurve,uRange,tRange,l)\ ==}\newline
608{\tt 9.\ \ \ }\newline
609{\tt 10.\ \ \ \ delT:DFLOAT\ :=\ (high(tRange)\ -\ low(tRange))/10000}\newline
610{\tt 11.\ \ \ \ oldT:DFLOAT\ :=\ low(tRange)\ -\ 1}\newline
611{\tt 12.\ \ \ \ fun\ :=\ ngeneralTube(spaceCurve,planeCurve,delT,oldT)}\newline
612{\tt 13.\ \ \ \ draw(fun,\ uRange,\ tRange,\ l)}\newline
613{\tt 14.\ \ }\newline
614
615\noindent
616
617\userfun{nfrenetFrame}{\it (c, t, delT)}
618numerically computes the Frenet frame
619about the curve {\it c} at {\it t}.
620Parameter {\it delT} is a small number used to
621compute derivatives.
622
623\noindent
624{\tt 15.\ \ nfrenetFrame(c,\ t,\ delT)\ ==}\newline
625{\tt 16.\ \ \ \ f0\ :=\ c(t)}\newline
626{\tt 17.\ \ \ \ f1\ :=\ c(t+delT)}\newline
627{\tt 18.\ \ \ \ t0\ :=\ f1\ -\ f0}\newline
628{\tt 19.\ \ \ \ n0\ :=\ f1\ +\ f0}\newline
629{\tt 20.\ \ \ \ b\ :=\ cross(t0,\ n0)}\newline
630{\tt 21.\ \ \ \ n\ :=\ cross(b,t0)}\newline
631{\tt 22.\ \ \ \ ln\ :=\ length\ n}\newline
632{\tt 23.\ \ \ \ lb\ :=\ length\ b}\newline
633{\tt 24.\ \ \ \ ln\ =\ 0\ or\ lb\ =\ 0\ =>}\newline
634{\tt 25.\ \ \ \ \ \ \ \ error\ "Frenet\ Frame\ not\ well\ defined"}\newline
635{\tt 26.\ \ \ \ n\ :=\ (1/ln)*n}\newline
636{\tt 27.\ \ \ \ b\ :=\ (1/lb)*b}\newline
637{\tt 28.\ \ \ \ [f0,\ t0,\ n,\ b]\$FrenetFrame}\newline
638
639\noindent
640
641\userfun{ngeneralTube}{\it (spaceCurve, planeCurve,}{\it  delT, oltT)}
642creates a function that can be passed to the system \spadfun{draw} command.
643The function is a parameterized surface for the general tube
644around {\it spaceCurve}.  {\it delT} is a small number used to compute
645derivatives. {\it oldT} is used to hold the current value of the
646{\it t} parameter for {\it spaceCurve.}  This is an efficiency measure
647to ensure that frames are only computed once for each value of {\it t}.
648
649\noindent
650{\tt 29.\ \ ngeneralTube:\ (ThreeCurve,\ TwoCurve,\ DFLOAT,\ DFLOAT)\ ->\ Surface}\newline
651{\tt 30.\ \ ngeneralTube(spaceCurve,\ planeCurve,\ delT,\ oldT)\ ==}\newline
652{\tt 31.\ \ \ \ free\ frame}\newline
653{\tt 32.\ \ \ \ (v:DFLOAT,\ t:\ DFLOAT):\ R3\ +->}\newline
654{\tt 33.\ \ \ \ \ \ if\ (t\ \notequal{}\ oldT)\ then}\newline
655{\tt 34.\ \ \ \ \ \ \ \ frame\ :=\ nfrenetFrame(spaceCurve,\ t,\ delT)}\newline
656{\tt 35.\ \ \ \ \ \ \ \ oldT\ :=\ t}\newline
657{\tt 36.\ \ \ \ \ \ p\ :=\ planeCurve(v,\ t)}\newline
658{\tt 37.\ \ \ \ \ \ frame.value\ +\ p.1*frame.normal\ +\ p.2*frame.binormal}\newline
659
660\noindent
661
662%\input{gallery/dhtri.htex}
663\endscroll
664\autobuttons
665\end{page}
666%
667%
668\newcommand{\ugFdhtriTitle}{dhtri.input}
669\newcommand{\ugFdhtriNumber}{G.11.}
670%
671% =====================================================================
672\begin{page}{ugFdhtriPage}{G.11. dhtri.input}
673% =====================================================================
674\beginscroll
675%
676Create affine transformations (DH matrices) that transform
677a given triangle into another.
678
679
680\noindent
681{\tt 1.\ \ \ tri2tri:\ (List\ Point\ DFLOAT,\ List\ Point\ DFLOAT)\ ->\ DHMATRIX(DFLOAT)}\newline
682{\tt 2.\ \ \ }\newline
683{\tt 3.\ \ \ tri2tri(t1,\ t2)\ ==}\newline
684{\tt 4.\ \ \ \ \ n1\ :=\ triangleNormal(t1)}\newline
685{\tt 5.\ \ \ \ \ n2\ :=\ triangleNormal(t2)}\newline
686{\tt 6.\ \ \ \ \ tet2tet(concat(t1,\ n1),\ concat(t2,\ n2))}\newline
687{\tt 7.\ \ \ }\newline
688{\tt 8.\ \ \ tet2tet:\ (List\ Point\ DFLOAT,\ List\ Point\ DFLOAT)\ ->\ DHMATRIX(DFLOAT)}\newline
689{\tt 9.\ \ \ }\newline
690{\tt 10.\ \ tet2tet(t1,\ t2)\ ==}\newline
691{\tt 11.\ \ \ \ m1\ :=\ makeColumnMatrix\ t1}\newline
692{\tt 12.\ \ \ \ m2\ :=\ makeColumnMatrix\ t2}\newline
693{\tt 13.\ \ \ \ m2\ *\ inverse(m1)}\newline
694{\tt 14.\ \ }\newline
695{\tt 15.\ \ makeColumnMatrix(t)\ ==}\newline
696{\tt 16.\ \ \ \ m\ :=\ new(4,4,0)\$DHMATRIX(DFLOAT)}\newline
697{\tt 17.\ \ \ \ for\ x\ in\ t\ for\ i\ in\ 1..repeat}\newline
698{\tt 18.\ \ \ \ \ \ for\ j\ in\ 1..3\ repeat}\newline
699{\tt 19.\ \ \ \ \ \ \ \ m(j,i)\ :=\ x.j}\newline
700{\tt 20.\ \ \ \ \ \ m(4,i)\ :=\ 1}\newline
701{\tt 21.\ \ \ \ m}\newline
702{\tt 22.\ \ }\newline
703{\tt 23.\ \ triangleNormal(t)\ ==}\newline
704{\tt 24.\ \ \ \ a\ :=\ triangleArea\ t}\newline
705{\tt 25.\ \ \ \ p1\ :=\ t.2\ -\ t.1}\newline
706{\tt 26.\ \ \ \ p2\ :=\ t.3\ -\ t.2}\newline
707{\tt 27.\ \ \ \ c\ :=\ cross(p1,\ p2)}\newline
708{\tt 28.\ \ \ \ len\ :=\ length(c)}\newline
709{\tt 29.\ \ \ \ len\ =\ 0\ =>\ error\ "degenerate\ triangle!"}\newline
710{\tt 30.\ \ \ \ c\ :=\ (1/len)*c}\newline
711{\tt 31.\ \ \ \ t.1\ +\ sqrt(a)\ *\ c}\newline
712{\tt 32.\ \ }\newline
713{\tt 33.\ \ triangleArea\ t\ ==}\newline
714{\tt 34.\ \ \ \ a\ :=\ length(t.2\ -\ t.1)}\newline
715{\tt 35.\ \ \ \ b\ :=\ length(t.3\ -\ t.2)}\newline
716{\tt 36.\ \ \ \ c\ :=\ length(t.1\ -\ t.3)}\newline
717{\tt 37.\ \ \ \ s\ :=\ (a+b+c)/2}\newline
718{\tt 38.\ \ \ \ sqrt(s*(s-a)*(s-b)*(s-c))}\newline
719
720\noindent
721
722
723\endscroll
724\autobuttons
725\end{page}
726%
727%
728\newcommand{\ugFtetraTitle}{tetra.input}
729\newcommand{\ugFtetraNumber}{G.12.}
730%
731% =====================================================================
732\begin{page}{ugFtetraPage}{G.12. tetra.input}
733% =====================================================================
734\beginscroll
735%
736%\input{gallery/tetra.htex}
737%\outdent{Sierpinsky's Tetrahedron}
738
739
740\noindent
741{\tt 1.\ \ \ )set\ expose\ add\ con\ DenavitHartenbergMatrix}\newline
742{\tt 2.\ \ \ }\newline
743{\tt 3.\ \ \ x1:DFLOAT\ :=\ sqrt(2.0@DFLOAT/3.0@DFLOAT)}\newline
744{\tt 4.\ \ \ x2:DFLOAT\ :=\ sqrt(3.0@DFLOAT)/6}\newline
745{\tt 5.\ \ \ }\newline
746{\tt 6.\ \ \ z\ :=\ 0.0@DFLOAT}\newline
747{\tt 7.\ \ \ h\ :=\ 0.5@DFLOAT}\newline
748{\tt 8.\ \ \ }\newline
749{\tt 9.\ \ \ p1\ :=\ point\ [-h,\ -x2,\ z]}\newline
750{\tt 10.\ \ p2\ :=\ point\ [h,\ -x2,\ z]}\newline
751{\tt 11.\ \ p3\ :=\ point\ [z,\ 2*x2,\ z]}\newline
752{\tt 12.\ \ p4\ :=\ point\ [z,\ z,\ x1]}\newline
753{\tt 13.\ \ }\newline
754{\tt 14.\ \ baseTriangle\ \ :=\ [p2,\ p1,\ p3]}\newline
755{\tt 15.\ \ }\newline
756{\tt 16.\ \ mt\ :=\ [h*(p2+p1),\ h*(p1+p3),\ h*(p3+p2)]}\newline
757{\tt 17.\ \ }\newline
758{\tt 18.\ \ bt1\ :=\ [mt.1,\ p1,\ mt.2]}\newline
759{\tt 19.\ \ bt2\ :=\ [p2,\ mt.1,\ mt.3]}\newline
760{\tt 20.\ \ bt3\ :=\ [mt.2,\ p3,\ mt.3]}\newline
761{\tt 21.\ \ bt4\ :=\ [h*(p2+p4),\ h*(p1+p4),\ h*(p3+p4)]}\newline
762{\tt 22.\ \ }\newline
763{\tt 23.\ \ tt1\ :=\ tri2tri(baseTriangle,\ bt1)}\newline
764{\tt 24.\ \ tt2\ :=\ tri2tri(baseTriangle,\ bt2)}\newline
765{\tt 25.\ \ tt3\ :=\ tri2tri(baseTriangle,\ bt3)}\newline
766{\tt 26.\ \ tt4\ :=\ tri2tri(baseTriangle,\ bt4)}\newline
767{\tt 27.\ \ }\newline
768{\tt 28.\ \ drawPyramid(n)\ ==}\newline
769{\tt 29.\ \ \ \ s\ :=\ createThreeSpace()}\newline
770{\tt 30.\ \ \ \ dh\ :=\ rotatex(0.0@DFLOAT)}\newline
771{\tt 31.\ \ \ \ drawPyramidInner(s,\ n,\ dh)}\newline
772{\tt 32.\ \ \ \ makeViewport3D(s,\ "Sierpinsky\ Tetrahedron")}\newline
773{\tt 33.\ \ }\newline
774{\tt 34.\ \ drawPyramidInner(s,\ n,\ dh)\ ==}\newline
775{\tt 35.\ \ \ \ n\ =\ 0\ =>\ makeTetrahedron(s,\ dh,\ n)}\newline
776{\tt 36.\ \ \ \ drawPyramidInner(s,\ n-1,\ dh\ *\ tt1)}\newline
777{\tt 37.\ \ \ \ drawPyramidInner(s,\ n-1,\ dh\ *\ tt2)}\newline
778{\tt 38.\ \ \ \ drawPyramidInner(s,\ n-1,\ dh\ *\ tt3)}\newline
779{\tt 39.\ \ \ \ drawPyramidInner(s,\ n-1,\ dh\ *\ tt4)}\newline
780{\tt 40.\ \ }\newline
781{\tt 41.\ \ makeTetrahedron(sp,\ dh,\ color)\ ==}\newline
782{\tt 42.\ \ \ \ w1\ :=\ dh*p1}\newline
783{\tt 43.\ \ \ \ w2\ :=\ dh*p2}\newline
784{\tt 44.\ \ \ \ w3\ :=\ dh*p3}\newline
785{\tt 45.\ \ \ \ w4\ :=\ dh*p4}\newline
786{\tt 46.\ \ \ \ polygon(sp,\ [w1,\ w2,\ w4])}\newline
787{\tt 47.\ \ \ \ polygon(sp,\ [w1,\ w3,\ w4])}\newline
788{\tt 48.\ \ \ \ polygon(sp,\ [w2,\ w3,\ w4])}\newline
789{\tt 49.\ \ \ \ void()}\newline
790
791\noindent
792%-% \HDindex{Sierpinsky's Tetrahedron}{ugFtetraPage}{G.12.}{tetra.input}
793
794
795%\input{gallery/antoine.htex}
796\endscroll
797\autobuttons
798\end{page}
799%
800%
801\newcommand{\ugFantoineTitle}{antoine.input}
802\newcommand{\ugFantoineNumber}{G.13.}
803%
804% =====================================================================
805\begin{page}{ugFantoinePage}{G.13. antoine.input}
806% =====================================================================
807\beginscroll
808%
809Draw Antoine's Necklace.
810%-% \HDindex{Antoine's Necklace}{ugFantoinePage}{G.13.}{antoine.input}
811Thank you to Matthew Grayson at IBM's T.J Watson Research Center for the idea.
812
813
814\noindent
815{\tt 1.\ \ \ )set\ expose\ add\ con\ DenavitHartenbergMatrix}\newline
816{\tt 2.\ \ \ }\newline
817{\tt 3.\ \ \ torusRot:\ DHMATRIX(DFLOAT)}\newline
818{\tt 4.\ \ \ }\newline
819{\tt 5.\ \ \ }\newline
820{\tt 6.\ \ \ drawRings(n)\ ==}\newline
821{\tt 7.\ \ \ \ \ s\ :=\ createThreeSpace()}\newline
822{\tt 8.\ \ \ \ \ dh:DHMATRIX(DFLOAT)\ :=\ identity()}\newline
823{\tt 9.\ \ \ \ \ drawRingsInner(s,\ n,\ dh)}\newline
824{\tt 10.\ \ \ \ makeViewport3D(s,\ "Antoine's\ Necklace")}\newline
825{\tt 11.\ \ }\newline
826
827\noindent
828
829In order to draw Antoine rings, we take one ring, scale it down to
830a smaller size, rotate it around its central axis, translate it
831to the edge of the larger ring and rotate it around the edge to
832a point corresponding to its count (there are 10 positions around
833the edge of the larger ring). For each of these new rings we
834recursively perform the operations, each ring becoming 10 smaller
835rings. Notice how the \spadtype{DHMATRIX} operations are used to build up
836the proper matrix composing all these transformations.
837
838
839\noindent
840{\tt 1.\ \ \ F\ ==>\ DFLOAT}\newline
841{\tt 2.\ \ \ drawRingsInner(s,\ n,\ dh)\ ==}\newline
842{\tt 3.\ \ \ \ \ n\ =\ 0\ =>}\newline
843{\tt 4.\ \ \ \ \ \ \ drawRing(s,\ dh)}\newline
844{\tt 5.\ \ \ \ \ \ \ void()}\newline
845{\tt 6.\ \ \ \ \ t\ :=\ 0.0@F}\newline
846{\tt 7.\ \ \ \ \ p\ :=\ 0.0@F}\newline
847{\tt 8.\ \ \ \ \ tr\ :=\ 1.0@F}\newline
848{\tt 9.\ \ \ \ \ inc\ :=\ 0.1@F}\newline
849{\tt 10.\ \ \ \ for\ i\ in\ 1..10\ repeat}\newline
850{\tt 11.\ \ \ \ \ \ tr\ :=\ tr\ +\ inc}\newline
851{\tt 12.\ \ \ \ \ \ inc\ :=\ -inc}\newline
852{\tt 13.\ \ \ \ \ \ dh'\ :=\ dh*rotatez(t)*translate(tr,0.0@F,0.0@F)*}\newline
853{\tt 14.\ \ \ \ \ \ \ \ \ \ \ \ \ rotatey(p)*scale(0.35@F,\ 0.48@F,\ 0.4@F)}\newline
854{\tt 15.\ \ \ \ \ \ drawRingsInner(s,\ n-1,\ dh')}\newline
855{\tt 16.\ \ \ \ \ \ t\ :=\ t\ +\ 36.0@F}\newline
856{\tt 17.\ \ \ \ \ \ p\ :=\ p\ +\ 90.0@F}\newline
857{\tt 18.\ \ \ \ void()}\newline
858{\tt 19.\ \ }\newline
859{\tt 20.\ \ drawRing(s,\ dh)\ ==}\newline
860{\tt 21.\ \ \ \ free\ torusRot}\newline
861{\tt 22.\ \ \ \ torusRot\ :=\ dh}\newline
862{\tt 23.\ \ \ \ makeObject(torus,\ 0..2*\%pi,\ 0..2*\%pi,\ var1Steps\ ==\ 6,}\newline
863{\tt 24.\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ space\ ==\ s,\ var2Steps\ ==\ 15)}\newline
864{\tt 25.\ \ }\newline
865{\tt 26.\ \ torus(u\ ,v)\ ==}\newline
866{\tt 27.\ \ \ \ cu\ :=\ cos(u)/6}\newline
867{\tt 28.\ \ \ \ torusRot*point\ [(1+cu)*cos(v),(1+cu)*sin(v),(sin\ u)/6]}\newline
868
869\noindent
870
871%\input{gallery/scherk.htex}
872\endscroll
873\autobuttons
874\end{page}
875%
876%
877\newcommand{\ugFscherkTitle}{scherk.input}
878\newcommand{\ugFscherkNumber}{G.14.}
879%
880% =====================================================================
881\begin{page}{ugFscherkPage}{G.14. scherk.input}
882% =====================================================================
883\beginscroll
884%
885
886Scherk's minimal surface, defined by:
887%-% \HDindex{Scherk's minimal surface}{ugFscherkPage}{G.14.}{scherk.input}
888\spad{exp(z) * cos(x) = cos(y)}.
889See: {\it A Comprehensive Introduction to Differential Geometry,} Vol. 3,
890by Michael Spivak, Publish Or Perish, Berkeley, 1979, pp. 249-252.
891
892
893\noindent
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
934
935\noindent
936\endscroll
937\autobuttons
938\end{page}
939%
940