aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/graphics.ht
blob: 9dfa9ca2cbdaf0f428732132f66b9f7d2d05cd7a (plain)
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
% Copyright The Numerical Algorithms Group Limited 1991.
% Certain derivative-work portions Copyright (C) 1988 by Leslie Lamport.
% All rights reserved

% Graphics Page
% @(#)graphics.ht       1.9 91/05/29 15:31:14
%%%%%%%%%%%
%% Pages %%
%%%%%%%%%%%

\begin{page}{GraphicsPage}{Graphics}
\Language{} can plot curves and surfaces of
various types, as well as lists of points in the plane.
% sequences, and complex functions.
\beginscroll
\beginmenu
\menulink{Examples}{GraphicsExamplePage} \tab{13}
See examples of \Language{} graphics
\menulink{2D Graphics}{TwoDimensionalGraphicsPage} \tab{13}
Graphics in the real and complex plane
\menulink{3D Graphics}{ThreeDimensionalGraphicsPage} \tab{13}
Plot surfaces, curves, or tubes around curves
\menulink{Viewports}{ViewportPage} \tab{13}
Customize graphics using Viewports
\endmenu
\endscroll
\autobuttons \end{page}

% Graphics Example Page

\begin{page}{GraphicsExamplePage}{Examples}
\beginscroll
Here are some examples of \Language{} graphics.
Choose a specific type of graph or choose Assorted Examples.
\beginmenu
\menulink{Assorted Examples}{AssortedGraphicsExamplePage} \newline
Examples of each type of \Language{} graphics.
\menulink{Three Dimensional Graphics}{ThreeDimensionalGraphicsExamplePage} \newline
Plot parametrically defined surfaces of three functions.
\menulink{Functions of One Variable}{OneVariableGraphicsExamplePage} \newline
Plot curves defined by an equation y = f(x).
\menulink{Parametric Curves}{ParametricCurveGraphicsExamplePage} \newline
Plot curves defined by parametric equations x = f(t), y = g(t).
\menulink{Polar Coordinates}{PolarGraphicsExamplePage} \newline
Plot curves given in polar form by an equation r = f(theta).
\menulink{Implicit Curves}{ImplicitCurveGraphicsExamplePage} \newline
Plot non-singular curves defined by a polynomial equation
\menulink{Lists of Points}{ListPointsGraphicsExamplePage} \newline
Plot lists of points in the (x,y)-plane.
% \menulink{Sequences}{SequenceGraphicsExamplePage}
% Plot a sequence a1, a2, a3,...
% \menulink{Complex Functions}{ComplexFunctionGraphicsExamplePage}
% Plot complex functions of a complex variable by means of grid plots.
\endmenu
\endscroll
\autobuttons \end{page}

% Assorted Graphics Example Page

\begin{page}{AssortedGraphicsExamplePage}{Assorted Examples}
\beginscroll
Pick a specific example or choose 'All' to see all the examples.\newline
Function of two variables: z = f(x,y).
\graphpaste{draw(sin(x * y), x = -2.5..2.5, y = -2.5..2.5) \bound{example1}}
Function of one variable: y = f(x).
\graphpaste{draw(sin tan x - tan sin x,x = 0..6) \bound{example2} }
Plane parametric curve: x = f(t), y = g(t).
\graphpaste{draw(curve(sin(t)*sin(2*t), sin(3*t)*sin(4*t)), t = 0..2*\%pi) \bound{example3}}
Space parametric curve: x = f(t), y = g(t), z = h(t).
\graphpaste{draw(curve(sin(t)*sin(2*t), sin(3*t)*sin(4*t), sin(5*t)*sin(6*t)), t = 0..2*\%pi) \bound{example4}}
Polar coordinates: r = f(theta).
\graphpaste{draw(sin(17*t), t = 0..2*\%pi, coordinates == polar) \bound{example5}}
Implicit curves: p(x,y) = 0.
\graphpaste{draw(y**2 + y = x**3 - x, x, y,range == \[-2..2,-2..1\]) \bound{example6}}
Run all examples.
\spadpaste{All \free{example1 example2 example3 example4 example5 example6}}
\endscroll
\autobuttons \end{page}

% Three Dimensional Graphics Example Page

\begin{page}{ThreeDimensionalGraphicsExamplePage}{Three Dimensional Graphics}
Plots of parametric surfaces defined by functions f(u,v), g(u,v), and h(u,v).
Choose a particular example or choose 'All' to see all the examples.
\beginscroll
Pear Surface.
\graphpaste{draw(surface((1+exp(-100*u*u))*sin(\%pi*u)*sin(\%pi*v), (1+exp(-100*u*u))*sin(\%pi*u)*cos(\%pi*v), (1+exp(-100*u*u))*cos(\%pi*u)), u=0..1, v=0..2, title=="Pear") \bound{example1}}
Trigonometric Screw.
\graphpaste{draw(surface(x*cos(y),x*sin(y),y*cos(x)), x=-4..4, y=0..2*\%pi, var1Steps==40, var2Steps==40, title=="Trig Screw") \bound{example2}}
Etruscan Venus. \newline
(click on the draw button to execute this example)
\spadpaste{a := 1.3 * cos(2*x) * cos(y) + sin(y) * cos(x)\bound{a}} 
\newline
\spadpaste{b := 1.3 * sin(2*x) * cos(y) - sin(y) * sin(x)\bound{b}} 
\newline
\spadpaste{c := 2.5 * cos(y) \bound{c}} 
\newline
\graphpaste{draw(surface(a,b,c), x=0..\%pi, y=-\%pi..\%pi, var1Steps==40, var2Steps==40, title=="Etruscan Venus") \free{a b c} \bound{example3}}
Banchoff Klein Bottle. \newline
(click on the draw button to execute this example)
\spadpaste{f:=cos(x)*(cos(x/2)*(sqrt(2) + cos(y))+(sin(x/2)*sin(y)*cos(y)))\bound{f}} 
\newline
\spadpaste{g:=sin(x)*(cos(x/2)*(sqrt(2) + cos(y))+(sin(x/2)*sin(y)*cos(y)))\bound{g}} 
\newline
\spadpaste{h:=-sin(x/2)*(sqrt(2)+cos(y)) + cos(x/2)*sin(y)*cos(y) \bound{h}}
\newline
\graphpaste{draw(surface(f,g,h), x=0..4*\%pi, y=0..2*\%pi, var1Steps==50, var2Steps==50, title=="Banchoff Klein Bottle") \free{f g h} \bound{example4}}
\newline
\spadpaste{All \free{example1 example2 example3 example4}}
\endscroll
\autobuttons \end{page}

% Functions of One Variable Example Page

\begin{page}{OneVariableGraphicsExamplePage}{Functions of One Variable}
\beginscroll
Plots of functions y = f(x).
Choose a particular example or choose 'All' to see all the examples.
\graphpaste{draw(sin tan x - tan sin x, x = 0..6) \bound{example1}}
\newline
\graphpaste{draw(sin x + cos x, x = 0..2*\%pi) \bound{example2}}
\newline
\graphpaste{draw(sin(1/x), x = -1..1) \bound{example3}}
\newline
\graphpaste{draw(x * sin(1/x), x = -1..1) \bound{example4}}
\newline
\spadpaste{All \free{example1 example2 example3 example4}}
\endscroll
\autobuttons \end{page}

% Parametric Curve Example Page

\begin{page}{ParametricCurveGraphicsExamplePage}{Parametric Curves}
Plots of parametric curves x = f(t), y = g(t).
Pick a particular example or choose 'All' to see all the examples.
\beginscroll
The Lemniscate of Bernoulli.
\graphpaste{draw(curve(cos(t/(1+sin(t)**2)), sin(t)*cos(t)/(1+sin(t)**2)), t = -\%pi..\%pi) \bound{example1}}
Lissajous curve.
\graphpaste{draw(curve(9*sin(3*t/4), 8*sin(t)), t = -4*\%pi..4*\%pi) \bound{example2}}
A gnarly closed curve.
\graphpaste{draw(curve(sin(t)*sin(2*t)*sin(3*t), sin(4*t)*sin(5*t)*sin(6*t)),t = 0..2*\%pi)
             \bound{example3}}
Another closed curve.
\graphpaste{draw(curve(cos(4*t)*cos(7*t), cos(4*t)*sin(7*t)), t = 0..2*\%pi) \bound{example4}}
Run all examples on this page.
\spadpaste{All \free{example1 example2 example3 example4}}
\endscroll
\autobuttons \end{page}

% Polar Coordinates Example Page

\begin{page}{PolarGraphicsExamplePage}{Polar Coordinates}
Plots of curves given by an equation in polar coordinates, r = f(theta).
Pick a particular example or choose 'All' to see all the examples.
\beginscroll
A Circle.
\graphpaste{draw(1,t = 0..2*\%pi, coordinates == polar) \bound{example1} }
A Spiral.
\graphpaste{draw(t,t = 0..100, coordinates == polar) \bound{example2} }
A Petal Curve.
\graphpaste{draw(sin(4*t), t = 0..2*\%pi, coordinates == polar) \bound{example3} }
A Limacon.
\graphpaste{draw(2 + 3 * sin t, t = 0..2*\%pi, coordinates == polar) \bound{example4} }
Run all examples on this page.
\spadpaste{All \free{
%example1
example2 example3 example4}}
\endscroll
\autobuttons \end{page}

% Implicit Curve Example Page

\begin{page}{ImplicitCurveGraphicsExamplePage}{Implicit Curves}
Non-singular curves defined by a polynomial equation p(x,y) = 0
in a rectangular region in the plane.
Pick a particular example or choose 'All' to see all the examples.
\beginscroll
A Conic Section (Hyperbola).
\graphpaste{draw(x * y = 1, x, y, range == \[-3..3, -3..3\]) \bound{example1} }
An Elliptic Curve.
\graphpaste{draw(y**2 + y = x**3 - x, x, y, range == \[-2..2, -2..1\]) \bound{example2} }
Cartesian Ovals.
\spadpaste{p := ((x**2 + y**2 + 1) - 8*x)**2 - (8*(x**2 + y**2 + 1) - 4*x - 1) \bound{p} }
\graphpaste{draw(p = 0, x, y, range == \[-1..11, -7..7\], title == "Cartesian Ovals") \free{p} \bound{example3} }
Cassinian Ovals: two loops.
\spadpaste{q := (x**2 + y**2 + 7**2)**2 - (6**4 + 4*7**2*x**2) \bound{q} }
\graphpaste{draw(q = 0, x, y, range == \[-10..10, -4..4\], title == "Cassinian oval with two loops") \free{q} \bound{example4} }
Run all examples on this page.
\spadpaste{All \free{example1 example2 example3 example4}}
\endscroll
\autobuttons \end{page}

% Lists of Points Example Page

\menulink{Lists of Points}{ListPointsGraphicsExamplePage} \newline

\begin{page}{ListPointsGraphicsExamplePage}{Lists of Points}
\Language{} has the ability to create lists of points in a two dimensional
graphics viewport.  This is done by utilizing the \spadtype{GraphImage} and
\spadtype{TwoDimensionalViewport} domain facilities.
\beginscroll
\indent{5}\newline
{\em NOTE:  It is only necessary to click on the makeViewport2D command button to plot this curve example}.
\indent{0}\newline
\spadpaste{p1 := point [1::SF,1::SF]\$(Point SF) \bound{p1}} 
\newline
\spadpaste{p2 := point [0::SF,1::SF]\$(Point SF) \bound{p2}} 
\newline
\spadpaste{p3 := point [0::SF,0::SF]\$(Point SF) \bound{p3}} 
\newline
\spadpaste{p4 := point [1::SF,0::SF]\$(Point SF) \bound{p4}} 
\newline
\spadpaste{p5 := point [1::SF,.5::SF]\$(Point SF) \bound{p5}} 
\newline
\spadpaste{p6 := point [.5::SF,0::SF]\$(Point SF) \bound{p6}} 
\newline
\spadpaste{p7 := point [0::SF,0.5::SF]\$(Point SF) \bound{p7}} 
\newline
\spadpaste{p8 := point [.5::SF,1::SF]\$(Point SF) \bound{p8}} 
\newline
\spadpaste{p9 := point [.25::SF,.25::SF]\$(Point SF) \bound{p9}} 
\newline
\spadpaste{p10 := point [.25::SF,.75::SF]\$(Point SF) \bound{p10}} 
\newline
\spadpaste{p11 := point [.75::SF,.75::SF]\$(Point SF) \bound{p11}} 
\newline
\spadpaste{p12 := point [.75::SF,.25::SF]\$(Point SF) \bound{p12}} 
\newline
\spadpaste{llp := [[p1,p2],[p2,p3],[p3,p4],[p4,p1],[p5,p6],[p6,p7],[p7,p8],[p8,p5],[p9,p10],[p10,p11],[p11,p12],[p12,p9]] \bound{llp} \free{p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12}} 
\newline
\spadpaste{size1 := 6::PositiveInteger \bound{size1}} 
\newline
\spadpaste{size2 := 8::PositiveInteger \bound{size2}} 
\newline
\spadpaste{size3 := 10::PositiveInteger \bound{size3}} 
\newline
\spadpaste{lsize := [size1, size1, size1, size1, size2, size2, size2, size2, size3, size3, size3, size3] \bound{lsize} \free{size1 size2 size3}} 
\newline
\spadpaste{pc1 := pastel red() \bound{pc1}} 
\newline
\spadpaste{pc2 := dim green() \bound{pc2}} 
\newline
\spadpaste{pc3 := pastel yellow() \bound{pc3}} 
\newline
\spadpaste{lpc := [pc1, pc1, pc1, pc1, pc2, pc2, pc2, pc2, pc3, pc3, pc3, pc3] \bound{lpc} \free{pc1 pc2 pc3}} 
\newline
\spadpaste{lc := [pastel blue(), light yellow(), dim green(), bright red(), light green(), dim yellow(), bright blue(), dark red(), pastel red(), light blue(), dim green(), light yellow()] \bound{lc}} 
\newline
\spadpaste{g := makeGraphImage(llp,lpc,lc,lsize)\$GRIMAGE \bound{g} \free{llp lpc lc lsize}} 
\newline
\graphpaste{makeViewport2D(g,[title("Lines")])\$VIEW2D \free{g}}
The \spadfun{makeViewport2D} command takes a list of options as a parameter
in this example.  The string "Lines" is designated as the viewport's title.
\endscroll
\autobuttons \end{page}

% Three Dimensional Graphics Page

\begin{page}{ThreeDimensionalGraphicsPage}{Three Dimensional Graphing}
\beginscroll
\beginmenu
\menulink{Functions of Two Variables}{TwoVariableGraphicsPage} \newline
Plot surfaces defined by an equation z = f(x,y).
\menulink{Parametric Curves}{SpaceCurveGraphicsPage} \newline
Plot curves defined by equations x = f(t), y = g(t), z = g(t).
\menulink{Parametric Tube Plots}{ParametricTubeGraphicsPage} \newline
Plot a tube around a parametric space curve.
\menulink{Parametric Surfaces}{ParametricSurfaceGraphicsPage} \newline
Plot surfaces defined by x = f(u,v), y = g(u,v), z = h(u,v).
\menulink{Building Objects}{ugGraphThreeDBuildPage} \newline
Create objects constructed from geometric primitives.
\endmenu
\endscroll
\autobuttons \end{page}

% Functions of Two Variables Graphics Page

\begin{page}{TwoVariableGraphicsPage}{Functions of Two Variables}
\beginscroll
This page describes the plotting of surfaces defined by an equation
of two variables, z = f(x,y), for which the ranges of x and y are explicitly
defined.  The basic draw command for this function utilizes either the
uncompiled function or compiled function format.  The general format for an
uncompiled function is:
\indent{5}\newline
{\em draw(f(x,y), x = a..b, y = c..d)}
\indent{0}\newline
where a..b and c..d are segments defining the intervals [a,b] and [c,d] over
which the variables x and y span.  In this case the function is not compiled
until the draw command is executed.  Here is an example:
\graphpaste{draw(cos(x*y),x=-3..3,y=-3..3)}
In the case of a compiled function, the function is named and compiled
independently.  This is useful if you intend to use a function often, or
if the function is long and complex.  The following line shows a function
whose parameters are of the type Small Float. The function is compiled and
stored by \Language{} when it is entered.
\indent{5}\newline
{\em NOTE:  It is only necessary to click on the draw command button to plot
this example}.
\indent{0}\newline
\spadpaste{f(x:SF,y:SF):SF == sin(x)*cos(y) \bound{f}}
\newline
Once the function is compiled the draw command only needs the name of the
function to execute.  Here is a compiled function example:
\graphpaste{draw(f,-\%pi..\%pi,-\%pi..\%pi) \free{f}}
Note that the parameter ranges do not take the variable names as in the
case of uncompiled functions.  The variables are entered in the order in
which they are defined in the function specification.  In this case the
first range specifies the x-variable and the second range specifies the
y-variable.
\endscroll
\autobuttons \end{page}

% Parametric Space Curves Graphics Page

\begin{page}{SpaceCurveGraphicsPage}{Parametric Space Curves}
\beginscroll
This page describes the plotting in three dimensional space of a curve
defined by the parametric equations x = f(t), y = g(t), z = h(t), where
f, g, and h are functions of the parameter t which ranges over a specified
interval.  The basic draw command for this function utilizes either the
uncompiled functions or compiled functions format and uses the \spadfun{curve}
command to specify the three functions for the x, y, and z components of
the curve.  The general format for uncompiled functions is:
\indent{5}\newline
{\em draw(curve(f(t),g(t),h(t)), t = a..b)}
\indent{0}\newline
where a..b is the segment defining the interval [a,b] over which the
parameter t ranges.  In this case the functions are not compiled until the
draw command is executed.  Here is an example:
\graphpaste{draw(curve(cos(t),sin(t),t), t=-12..12)}
In the case of compiled functions, the functions are named and compiled
independently.  This is useful if you intend to use the functions often, or
if the functions are long and complex.  The following lines show functions
whose parameters are of the type Small Float. The functions are compiled and
stored by \Language{} when entered.
\indent{5}\newline
{\em NOTE:  It is only necessary to click on the draw command button to plot
this example}.
\indent{0}\newline
\spadpaste{i1(t:SF):SF == sin(t)*cos(3*t/5) \bound{i1}}
\spadpaste{i2(t:SF):SF == cos(t)*cos(3*t/5) \bound{i2}}
\spadpaste{i3(t:SF):SF == cos(t)*sin(3*t/5) \bound{i3}}
Once the functions are compiled the draw command only needs the names of
the functions to execute.  Here is a compiled functions example:
\graphpaste{draw(curve(i1,i2,i3),0..15*\%pi) \free{i1 i2 i3}}
Note that the parameter range does not take the variable name as in the
case of uncompiled functions. It is understood that the indicated range
applies to the parameter of the functions, which in this case is t.
\endscroll
\autobuttons \end{page}

% Parametric Tube Plots Graphics Page

\begin{page}{ParametricTubeGraphicsPage}{Parametric Tube Plots}
\beginscroll
This page describes the plotting in three dimensional space of a tube
around a parametric space curve defined by the parametric equations
x = f(t), y = g(t), z = h(t), where f, g, and h are functions of the
parameter t which ranges over a specified interval.  The basic draw command
for this function utilizes either the uncompiled functions or compiled
functions format and uses the \spadfun{curve} command to specify the three
functions for the x, y, and z components of the curve.  This uses the same
format as that for space curves except that it requires a specification for
the radius of the tube.  If the radius of the tube is 0, then the result is
the space curve itself.  The general format for uncompiled functions is:
\indent{5}\newline
{\em draw(curve(f(t),g(t),h(t)), t = a..b, tubeRadius == r)}
\indent{0}\newline
where a..b is the segment defining the interval [a,b] over which the
parameter t ranges, and the tubeRadius is indicated by the variable r.
In this case the functions are not compiled until the draw command is
executed.  Here is an example:
\graphpaste{draw(curve(sin(t)*cos(3*t/5), cos(t)*cos(3*t/5), cos(t)*sin(3*t/5)), t=0..15*\%pi,tubeRadius == .15)}
In the case of compiled functions, the functions are named and compiled
independently.  This is useful if you intend to use the functions often, or
if the functions are long and complex.  The following lines show functions
whose parameters are of the type Small Float. The functions are compiled and
stored by \Language{} when entered.
\indent{5}\newline
{\em NOTE:  It is only necessary to click on the draw command button to plot
this example}.
\indent{0}\newline
\spadpaste{t1(t:SF):SF == 4/(2-sin(3*t))*cos(2*t) \bound{t1}} 
\newline
\spadpaste{t2(t:SF):SF == 4/(2-sin(3*t))*sin(2*t) \bound{t2}} 
\newline
\spadpaste{t3(t:SF):SF == 4/(2-sin(3*t))*cos(3*t) \bound{t3}} 
\newline
Once the function is compiled the draw command only needs the names of the
functions to execute.  Here is a compiled functions example of a trefoil knot:
\graphpaste{draw(curve(t1,t2,t3),0..2*\%pi,tubeRadius == .2) \free{t1 t2 t3}}
Note that the parameter range does not take the variable name as in the
case of uncompiled functions. It is understood that the indicated range
applies to the parameter of the functions, which in this case is t.
Typically, the radius of the tube should be set between 0 and 1.  A radius
of less than 0 results in it's positive counterpart and a radius of greater
than one causes self intersection.
\endscroll
\autobuttons \end{page}

% Parametric Surfaces Graphics Page

\begin{page}{ParametricSurfaceGraphicsPage}{Parametric Surfaces}
\beginscroll
Graphing a surface defined by x = f(u,v), y = g(u,v), z = h(u,v). \newline
This page describes the plotting of surfaces defined by the parametric
equations of two variables, x = f(u,v), y = g(u,v), and z = h(u,v),
for which the ranges of u and v are explicitly defined.  The basic draw
command for this function utilizes either the uncompiled function or
compiled function format and uses the \spadfun{surface} command to specify the
three functions for the x, y and z components of the surface.  The general
format for uncompiled functions is:
\indent{5}\newline
{\em draw(surface(f(u,v),g(u,v),h(u,v)), u = a..b, v = c..d)}
\indent{0}\newline
where a..b and c..d are segments defining the intervals [a,b] and [c,d] over
which the parameters u and v span.  In this case the functions are not
compiled until the draw command is executed.  Here is an example of a
surface plotted using the parabolic cylindrical coordinate system option:
\graphpaste{draw(surface(u*cos(v), u*sin(v),v*cos(u)),u=-4..4,v=0..2*\%pi,
                  coordinates== parabolicCylindrical)}
In the case of compiled functions, the functions are named and compiled
independently.  This is useful if you intend to use the functions often, or
if the functions are long and complex.  The following lines show functions
whose parameters are of the type Small Float. The functions are compiled and
stored by \Language{} when entered.
\indent{5}\newline
{\em NOTE:  It is only necessary to click on the draw command button to plot
this example}.
\indent{0}\newline
\spadpaste{n1(u:SF,v:SF):SF == u*cos(v) \bound{n1}} 
\newline
\spadpaste{n2(u:SF,v:SF):SF == u*sin(v) \bound{n2}} 
\newline
\spadpaste{n3(u:SF,v:SF):SF == u \bound{n3}}
Once the function is compiled the draw command only needs the names of the
functions to execute.  Here is a compiled functions example plotted using
the toroidal coordinate system option: \newline
\graphpaste{draw(surface(n1,n2,n3), 1.0..4.0, 1.0..4*\%pi,
             coordinates == toroidal(1\$SF)) \free{n1 n2 n3}}
Note that the parameter ranges do not take the variable names as in the
case of uncompiled functions.  The variables are entered in the order in
which they are defined in the function specification.  In this case the
first range specifies the u-variable and the second range specifies the
v-variable.
\endscroll
\autobuttons \end{page}

% Building 3D Objects Graphics Page

\begin{page}{3DObjectGraphicsPage}{Building 3D Objects}
\beginscroll
This page describes the \Language{} facilities for creating three dimensional
objects constructed from geometric primitives.  The \Language{} operation
\spadfun{create3Space()} creates a space to which points, curves, and
polygons can be added using the operations from the \spadtype{ThreeSpace}
domain.  The contents of this space can then be displayed in a viewport
using the \spadfun{makeViewport3D()} command.  It will be necessary to
have these operations exposed in order to use them. \indent{5}\newline
{\em NOTE:  It is only necessary to click on the makeViewport3D command button
to plot this curve example}.
\indent{0}\newline
Initially, the space which will hold the objects must be defined and
compiled, as in the following example:
\spadpaste{space := create3Space()\$(ThreeSpace SF) \bound{space}}
Now objects can be sent to this {\em space} as per the operations allowed by
the \spadtype{ThreeSpace} domain.  The following examples place curves into
{\em space}.
\spadpaste{curve(space,[[0,20,20],[0,20,30],[0,30,30],[0,30,100], [0,20,100],[0,20,110],[0,50,110],[0,50,100],[0,40,100], [0,40,30],[0,50,30],[0,50,20],[0,20,20]]) \bound{curveI}} 
\newline
\spadpaste{curve(space,[[0,80,20],[0,70,20],[0,70,110],[0,110,110], [0,120,100],[0,120,70],[0,115,65],[0,120,60],[0,120,30], [0,110,20],[0,80,20],[0,80,30],[0,105,30],[0,110,35]]) \bound{curveB1}} 
\newline
\spadpaste{curve(space,[[0,110,35],[0,110,55],[0,105,60],[0,80,60],[0,80,70], [0,105,70],[0,110,75],[0,110,95],[0,105,100],[0,80,100], [0,80,30]]) \bound{curveB2}} 
\newline
\spadpaste{closedCurve(space,[[0,140,20],[0,140,110],[0,150,110],[0,170,50], [0,190,110],[0,200,110],[0,200,20],[0,190,20],[0,190,75], [0,175,35],[0,165,35],[0,150,75],[0,150,20]]) \bound{curveM}}
\spadpaste{closedCurve(space,[[200,0,20], [200,0,110], [185,0,110], [160,0,45], [160,0,110], [150,0,110], [150,0,20], [165,0,20], [190,0,85], [190,0,20]]) \bound{curveN}}
\spadpaste{closedCurve(space,[[140,0,20], [120,0,110], [110,0,110], [90,0,20], [100,0,20], [108,0,50], [123,0,50], [121,0,60], [110,0,60], [115,0,90], [130,0,20]]) \bound{curveA}}
\spadpaste{closedCurve(space,[[80,0,30], [80,0,100], [70,0,110], [40,0,110], [30,0,100], [30,0,90], [40,0,90], [40,0,95], [45,0,100], [65,0,100], [70,0,95], [70,0,35], [65,0,30], [45,0,30], [40,0,35], [40,0,60], [50,0,60], [50,0,70], [30,0,70], [30,0,30], [40,0,20], [70,0,20]]) \bound{curveG}}
Once {\em space} contains the desired elements a viewport is created and
displayed with the following command:
\graphpaste{makeViewport3D(space,[title("Curves")])\$VIEW3D \free{space curveI curveB1 curveB2 curveM curveN curveA curveG}}
The parameters for \spadfun{makeViewport3D()} in this example are {\em space},
which is the name of the three dimensional space that was defined, and a
string, "curve", which is the title for the viewport.  The tailing string
{\em \$VIEW3D} exposes the command \spadfun{makeViewport3D()} from the domain
\spadtype{ThreeDimensionalViewport} if these commands are unexposed.
\endscroll
\autobuttons \end{page}

% Two Dimensional Graphics Page

\begin{page}{TwoDimensionalGraphicsPage}{Two Dimensional Graphics}
\beginscroll
\beginmenu
\menulink{Functions of One Variable}{OneVariableGraphicsPage} \newline
Plot curves defined by an equation y = f(x).
\menulink{Parametric Curves}{ParametricCurveGraphicsPage} \newline
Plot curves defined by parametric equations x = f(t), y = g(t).
\menulink{Polar Coordinates}{PolarGraphicsPage} \newline
Plot curves given in polar form by an equation r = f(theta).
\menulink{Implicit Curves}{ImplicitCurveGraphicsPage} \newline
Plot non-singular curves defined by a polynomial equation
\menulink{Lists of Points}{ListPointsGraphicsPage} \newline
Plot lists of points in the (x,y)-plane.
% \menulink{Sequences}{SeqGraphicsPage} \newline
% Plot a sequence a1, a2, a3,...
% \menulink{Complex Functions}{CxFuncGraphicsPage} \newline
% Plot functions of a complex variable using grid plots.
\endmenu
\endscroll
\autobuttons \end{page}

% Functions of One Variable Graphics Page

\begin{page}{OneVariableGraphicsPage}{Functions of One Variable}
\beginscroll
Here we wish to plot a function y = f(x) on an interval [a,b].
As an example, let's take the function y = sin(tan(x)) - tan(sin(x))
on the interval [0,6].
Here is the simplest command that will do this:
\graphpaste{draw(sin(tan(x)) - tan(sin(x)),x = 0..6)}
Notice that \Language{} compiled a function before the graph was put
on the screen.
The expression sin(tan(x)) - tan(sin(x)) was converted to a compiled
function so that it's value for various values of x could be computed
quickly and efficiently.
Let's graph the same function on a different interval and this time
we'll give the graph a title.
The title is a String, which is an optional argument of the command 'draw'.
\graphpaste{draw(sin(tan(x)) - tan(sin(x)),x = 10..16,title == "y = sin tan x - tan sin x")}
Once again the expression sin(tan(x)) - tan(sin(x)) was converted to a
compiled function before any points were computed.
If you want to graph the same function on a number of intervals, it's
a good idea to write down a function definition so that the function
only has to be compiled once.
Here's an example:
\spadpaste{f(x) == (x-1)*(x-2)*(x-3) \bound{f}}
\newline
\graphpaste{draw(f, 0..2, title == "y = f(x) on \[0,2\]") \free{f}}
\newline
\graphpaste{draw(f, 0..4,title == "y = f(x) on \[0,4\]") \free{f}}
Notice that our titles can be whatever we want, as long as they are
enclosed by double quotes.  However, a title which is too long to fit
within the viewport title window will be clipped.
\endscroll
\autobuttons \end{page}

% Parametric Curve Graphics Page

\begin{page}{ParametricCurveGraphicsPage}{Parametric Curves}
\beginscroll
One way of producing interesting curves is by using parametric equations.
Let x = f(t) and y = g(t) for two functions f and g as the parameter
t ranges over an interval \[a,b\].
Here's an example:
\graphpaste{draw(curve(sin(t)*sin(2*t)*sin(3*t), sin(4*t)*sin(5*t)*sin(6*t)), t = 0..2*\%pi)}
Here 0..2*\%pi represents the interval over which the variable t ranges.
In the case of parametric curves, \Language{} will compile two functions,
one for each of the functions f and g.
You may also put a title on a graph.
The title may be an arbitrary string and is an optional argument
to the command 'draw'.
For example:
\graphpaste{draw(curve(cos(t), sin(t)), t = 0..2*\%pi, title == "The Unit Circle")}
If you plan on plotting x = f(t), y = g(t) as t ranges over several intervals,
you may want to define functions f and g, so that they need not be
recompiled every time you create a new graph.
Here's an example:
\spadpaste{f(t:SF):SF == sin(3*t/4) \bound{f}} 
\newline
\spadpaste{g(t:SF):SF == sin(t) \bound{g}} 
\newline
\graphpaste{draw(curve(f,g), 0..\%pi) \free{f g}} 
\newline
\graphpaste{draw(curve(f,g) ,\%pi..2*\%pi) \free{f g}} 
\newline
\graphpaste{draw(curve(f,g), -4*\%pi..4*\%pi) \free{f g}}
These examples show how the curve changes as the range of parameter t varies.
\endscroll
\autobuttons \end{page}

% Polar Coordinates Graphics Page

\begin{page}{PolarGraphicsPage}{Polar Coordinates}
\beginscroll
Graphs in polar coordinates are given by an equation r = f(theta) as
theta ranges over an interval.
This is equivalent to the parametric curve x = f(theta) * cos(theta),
y = f(theta) * sin(theta) as theta ranges over the same interval.
You may create such curves using the command 'draw', with the optional
argument 'coordinates == polar'.
Here are some examples:
\graphpaste{draw(1,t = 0..2*\%pi,coordinates == polar, title == "The Unit Circle")} 
\newline
\graphpaste{draw(sin(17*t), t = 0..2*\%pi, coordinates == polar, title == "A Petal Curve")}
%When you don't specify an interval, \Language{} will assume that you
%mean 0..2*\%pi.
You may also define your own functions, when you plan on plotting the
same curve as theta varies over several intervals.
\spadpaste{f(t) == cos(4*t/7) \bound{f}} 
\newline
\graphpaste{draw(f, 0..2*\%pi, coordinates == polar) \free{f}} 
\newline
\graphpaste{draw(f, 0..14*\%pi, coordinates == polar) \free{f}}
For information on plotting graphs in other coordinate systems see the
pages for the \spadtype{CoordinateSystems} domain.
\endscroll
\autobuttons \end{page}

% Implicit Curve Graphics Page

\begin{page}{ImplicitCurveGraphicsPage}{Implicit Curves}
\beginscroll
\Language{} has facilities for graphing a non-singular algebraic curve
in a rectangular region of the plane.
An algebraic curve is a curve defined by a polynomial equation
p(x,y) = 0.
Non-singular means that the curve is "smooth" in that it does not
cross itself or come to a point (cusp).
Algebraically, this means that for any point (a,b) on the curve
(i.e. a point such that p(a,b) = 0), the partial derivatives
dp/dx(a,b) and dp/dy(a,b) are not both zero.
We require that the polynomial have rational or integral coefficients.
Here is a Cartesian ovals algebraic curve example:
(click on the draw button to execute this example)
\spadpaste{p := ((x**2 + y**2 + 1) - 8*x)**2 - (8*(x**2 + y**2 + 1) - 4*x - 1) \bound{p} }
\graphpaste{draw(p = 0, x, y, range == \[-1..11, -7..7\], title == "Cartesian Ovals") \free{p}}
{\em A range must be declared for each variable specified in the algebraic
curve equation}.
\endscroll
\autobuttons \end{page}

% List of Points Graphics Page

\begin{page}{ListPointsGraphicsPage}{Lists of Points}
\beginscroll
\Language{} has the ability to create lists of points in a two dimensional
graphics viewport.  This is done by utilizing the \spadtype{GraphImage} and
\spadtype{TwoDimensionalViewport} domain facilities.
\indent{5}\newline
{\em NOTE:  It is only necessary to click on the makeViewport2D command button
to plot this curve example}.
\indent{0}\newline
In this example, the \spadfun{makeGraphImage} command takes a list of lists of
points parameter, a list of colors for each point in the graph, a list of
colors for each line in the graph, and a list of numbers which indicate the
size of each point in the graph.  The following lines create list of lists of
points which can be read be made into two dimensional graph images.
\spadpaste{p1 := point [1::SF,1::SF]\$(Point SF) \bound{p1}} 
\newline
\spadpaste{p2 := point [0::SF,1::SF]\$(Point SF) \bound{p2}} 
\newline
\spadpaste{p3 := point [0::SF,0::SF]\$(Point SF) \bound{p3}} 
\newline
\spadpaste{p4 := point [1::SF,0::SF]\$(Point SF) \bound{p4}} 
\newline
\spadpaste{p5 := point [1::SF,.5::SF]\$(Point SF) \bound{p5}} 
\newline
\spadpaste{p6 := point [.5::SF,0::SF]\$(Point SF) \bound{p6}} 
\newline
\spadpaste{p7 := point [0::SF,0.5::SF]\$(Point SF) \bound{p7}} 
\newline
\spadpaste{p8 := point [.5::SF,1::SF]\$(Point SF) \bound{p8}} 
\newline
\spadpaste{p9 := point [.25::SF,.25::SF]\$(Point SF) \bound{p9}} 
\newline
\spadpaste{p10 := point [.25::SF,.75::SF]\$(Point SF) \bound{p10}} 
\newline
\spadpaste{p11 := point [.75::SF,.75::SF]\$(Point SF) \bound{p11}} 
\newline
\spadpaste{p12 := point [.75::SF,.25::SF]\$(Point SF) \bound{p12}} 
\newline
\spadpaste{llp := [[p1,p2],[p2,p3],[p3,p4],[p4,p1],[p5,p6],[p6,p7],[p7,p8],[p8,p5],[p9,p10],[p10,p11],[p11,p12],[p12,p9]] \bound{llp} \free{p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12}} 
\newline
These lines set the point color and size, and the line color for all components
of the graph.
\spadpaste{size1 := 6::PositiveInteger \bound{size1}} 
\newline
\spadpaste{size2 := 8::PositiveInteger \bound{size2}} 
\newline
\spadpaste{size3 := 10::PositiveInteger \bound{size3}} 
\newline
\spadpaste{lsize := [size1, size1, size1, size1, size2, size2, size2, size2, size3, size3, size3, size3] \bound{lsize} \free{size1 size2 size3}} 
\newline
\spadpaste{pc1 := pastel red() \bound{pc1}} 
\newline
\spadpaste{pc2 := dim green() \bound{pc2}} 
\newline
\spadpaste{pc3 := pastel yellow() \bound{pc3}} 
\newline
\spadpaste{lpc := [pc1, pc1, pc1, pc1, pc2, pc2, pc2, pc2, pc3, pc3, pc3, pc3] \bound{lpc} \free{pc1 pc2 pc3}} 
\newline
\spadpaste{lc := [pastel blue(), light yellow(), dim green(), bright red(), light green(), dim yellow(), bright blue(), dark red(), pastel red(), light blue(), dim green(), light yellow()] \bound{lc}} 
\newline
Now the graph image is created and named according to the component
specifications indicated above.  The \spadfun{makeViewport2D} command then
creates a two dimensional viewport for this graph according to the list of
options specified within the brackets.
\spadpaste{g := makeGraphImage(llp,lpc,lc,lsize)\$GRIMAGE \bound{g} \free{llp lpc lc lsize}} 
\newline
\graphpaste{makeViewport2D(g,[title("Lines")])\$VIEW2D \free{g}}
The \spadfun{makeViewport2D} command takes a list of options as a parameter.
In this example the string "Lines" is designated as the viewport's title.
\endscroll
\autobuttons \end{page}

% \begin{page}{SequenceGraphicsPage}{Sequences}
% \beginscroll
% \endscroll
% \autobuttons \end{page}

% \begin{page}{ComplexFunctionGraphicsPage}{Complex Functions}
% \beginscroll
% \endscroll
% \autobuttons \end{page}

\begin{page}{ViewportPage}{Stand-alone Viewport}
\beginscroll
To get a viewport on a \HyperName{} page, you first need to
create one in \Language{} and write it out to a
file that \HyperName{} can call up. \newline
For example, here we draw a saddle function and assign
the result to the variable \spad{v}:
\newline
\graphpaste{v := draw(x*x-y*y,x=-1..1,y=-1..1) \bound{v}} 
\newline
Now that we've created the viewport, we want to write
the data out to a file. \newline
To do this, we use the \spadfunFrom{write}{ThreeDimensionalViewport} command which takes
the following arguments: the viewport to write out,
the title of the file to write it out to, and an optional
argument telling the write command what type (or types) of
data you want to write in additional to the one \Language{} will
always write out. The optional argument could be
a string, like "pixmap", or a list of strings, like \["postscript","pixmap"\].
\HyperName{} needs a "pixmap" data type to include a graph in a page
so in this case, we write the viewport and tell it to
also write a "pixmap" file, as well:
\newline
\spadpaste{write(v,"saddle","pixmap") \free{v}}
\newline
Now we want to put this viewport into a \HyperName{} page.
Say you've created a viewport and written it out
to a file called "/tmp/mobius". (\Language{} actually
tags a ".VIEW" at the end of a viewport data file to
make it easier to spot when you're rummaging through
your file system, but you needn't worry about that here
since \Language{} will always automatically add on a
".VIEW" for you.)  \newline

{\bf Including Viewports} \newline
To put a viewport in a
\HyperName{} page, include the following line in your \HyperName{}
source code: \newline
\space{5}\\viewport\{/tmp/mobius\} \newline
You will get this on your page: \newline
%%%\space{4}\viewport{/tmp/mobius}\newline
%\space{4}\spadviewport{mobius}\newline
\centerline{\spadviewport{mobius}}\newline

{\bf Creating Viewport Buttons} \newline
To make an active button that would make this viewport
come to life, include the following: \newline
\space{5}\\viewportbutton\{ViewButton\}\{/tmp/mobius\} \newline
this creates this button...\newline
%%%\centerline{\viewportbutton{ViewButton}{/tmp/mobius}}\newline
\centerline{\spadviewportbutton{ViewButton}{mobius}}\newline

{\bf Creating Active Viewports} \newline
To merge the two things descibed above, namely, getting a picture of a
viewport and creating a button to invoke a live viewport, you can do
the following: \newline

%\space{5}\\viewportasbutton\{/tmp/mobius\} \newline
\centerline{\\viewportasbutton\{/tmp/mobius\}}\newline

This would create a picture of a viewport that is an active
button as well. Try it:

%%%\space{5}\viewportasbutton{/tmp/mobius} \newline
%\space{5}\spadviewportasbutton{mobius} \newline
\centerline{\spadviewportasbutton{mobius}}\newline

{\bf Including Viewports Distributed with \Language{}} \newline
All the above commands have counterparts that allow you to
access viewports that are already packaged with \Language{}.
To include those viewports, just add on an "axiom" prefix
to the above commands: \newline

\centerline{\\axiomviewport\{vA\} for \\viewport\{vA\}}
\centerline{\\axiomviewportbutton\{vB\} for \\viewportbutton\{vB\}}
\centerline{\\axiomviewportasbutton\{vC\} for \\viewportasbutton\{vC\}} \newline

All these macros really do is include some path that
indicates where \Language{} stores the viewports.
\newline
\endscroll
\autobuttons \end{page}