1--Copyright The Numerical Algorithms Group Limited 1994. 2 3-- Color gallery page 5 4 5 6-- Etruscan Venus 7-- Parameterization by George Frances 8 9venus(a,r,steps) == 10 surf := (u:DoubleFloat, v:DoubleFloat): Point DoubleFloat +-> 11 cv := cos(v) 12 sv := sin(v) 13 cu := cos(u) 14 su := sin(u) 15 x := r * cos(2*u) * cv + sv * cu 16 y := r * sin(2*u) * cv - sv * su 17 z := a * cv 18 point [x,y,z] 19 draw(surf, 0..%pi, -%pi..%pi, var1Steps==steps,var2Steps==steps, 20 title == "Etruscan Venus") 21 22venus(5/2, 13/10, 50) 23 24-- Figure Eight Klein Bottle 25-- Parameterization from: 26-- "Differential Geometry and Computer Graphics" by Thomas Banchoff 27-- in Perspectives in Mathemtaics, Anneversry of Oberwolfasch 1984. 28-- Beirkhauser-Verlag, Basel, pp 43-60. 29 30klein(x,y) == 31 cx := cos(x) 32 cy := cos(y) 33 sx := sin(x) 34 sy := sin(y) 35 sx2 := sin(x/2) 36 cx2 := cos(x/2) 37 sq2 := sqrt(2.0@DoubleFloat) 38 point [cx * (cx2 * (sq2 + cy) + (sx2 * sy * cy)), _ 39 sx * (cx2 * (sq2 + cy) + (sx2 * sy * cy)), _ 40 -sx2 * (sq2 + cy) + cx2 * sy * cy] 41 42draw(klein, 0..4*%pi, 0..2*%pi, var1Steps==50, var2Steps==50, _ 43 title=="Figure Eight Klein Bottle") 44 45-- Twisted torus 46 47)read ntube 48 49-- rotate a 2-d point by theta round the origin 50rotateBy(p, theta) == 51 c := cos(theta) 52 s := sin(theta) 53 point [p.1*c - p.2*s, p.1*s + p.2*c] 54 55-- a circle in 3-space 56bcircle t == 57 point [3*cos t, 3*sin t, 0] 58 59-- an ellipse which twists around 4 times as t revolves once. 60twist(u, t) == 61 theta := 4*t 62 p := point [sin u, cos(u)/2] 63 rotateBy(p, theta) 64 65ntubeDrawOpt(bcircle, twist, 0..2*%pi, 0..2*%pi, _ 66 var1Steps == 70, var2Steps == 250) 67 68-- Striped torus 69 70-- a twisting circle 71twist2(u, t) == 72 theta := t 73 p := point [sin u, cos(u)] 74 rotateBy(p, theta) 75 76-- color function producing 21 stripes 77cf(u,v) == sin(21*u) 78 79ntubeDrawOpt(bcircle, twist2, 0..2*%pi, 0..2*%pi, _ 80 colorFunction == cf, var1Steps == 168, var2Steps == 126) 81