"Fossies" - the Fresh Open Source Software Archive

Member "asymptote-2.60/examples/Klein.asy" (6 Nov 2019, 1309 Bytes) of package /linux/misc/asymptote-2.60.src.tgz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "Klein.asy": 2.53_vs_2.54.

    1 import graph3;
    2 
    3 size(469pt);
    4 
    5 currentprojection=perspective(
    6 camera=(25.0851928432063,-30.3337528952473,19.3728775115443),
    7 up=Z,
    8 target=(-0.590622314050054,0.692357205025578,-0.627122488455679),
    9 zoom=1,
   10 autoadjust=false);
   11 
   12 triple f(pair t) {
   13   real u=t.x;
   14   real v=t.y;
   15   real r=2-cos(u);
   16   real x=3*cos(u)*(1+sin(u))+r*cos(v)*(u < pi ? cos(u) : -1);
   17   real y=8*sin(u)+(u < pi ? r*sin(u)*cos(v) : 0);
   18   real z=r*sin(v);
   19   return (x,y,z);
   20 }
   21 
   22 surface s=surface(f,(0,0),(2pi,2pi),8,8,Spline);
   23 draw(s,lightolive+white,"bottle",render(merge=true));
   24 
   25 string lo="$\displaystyle u\in[0,\pi]: \cases{x=3\cos u(1+\sin u)+(2-\cos u)\cos u\cos v,\cr
   26 y=8\sin u+(2-\cos u)\sin u\cos v,\cr
   27 z=(2-\cos u)\sin v.\cr}$";
   28 
   29 string hi="$\displaystyle u\in[\pi,2\pi]:\\\cases{x=3\cos u(1+\sin u)-(2-\cos u)\cos v,\cr
   30 y=8\sin u,\cr
   31 z=(2-\cos u)\sin v.\cr}$";
   32 
   33 real h=0.0125;
   34 
   35 begingroup3("parametrization");
   36 draw(surface(xscale(-0.38)*yscale(-0.18)*lo,s,0,1.7,h,bottom=false),
   37      "[0,pi]");
   38 draw(surface(xscale(0.26)*yscale(0.1)*rotate(90)*hi,s,4.9,1.4,h,bottom=false),
   39      "[pi,2pi]");
   40 endgroup3();
   41 
   42 begingroup3("boundary");
   43 draw(s.uequals(0),blue+dashed);
   44 draw(s.uequals(pi),blue+dashed);
   45 endgroup3();
   46 
   47 add(new void(frame f, transform3 t, picture pic, projection P) {
   48     draw(f,invert(box(min(f,P),max(f,P)),P),"frame");
   49   });