diff options
Diffstat (limited to 'Build/source/utils/asymptote/examples')
17 files changed, 220 insertions, 30 deletions
diff --git a/Build/source/utils/asymptote/examples/Klein.asy b/Build/source/utils/asymptote/examples/Klein.asy index ba3bccd87e9..43199200276 100644 --- a/Build/source/utils/asymptote/examples/Klein.asy +++ b/Build/source/utils/asymptote/examples/Klein.asy @@ -14,6 +14,4 @@ triple f(pair t) { return (x,y,z); } -pen p=rgb(0.2,0.5,0.7); - -draw(surface(f,(0,0),(2pi,2pi),60,60),lightgray,meshpen=p); +draw(surface(f,(0,0),(2pi,2pi),8,8,Spline),lightgray); diff --git a/Build/source/utils/asymptote/examples/RiemannSurface.asy b/Build/source/utils/asymptote/examples/RiemannSurface.asy index 68c8f237a19..f32ca4d7539 100644 --- a/Build/source/utils/asymptote/examples/RiemannSurface.asy +++ b/Build/source/utils/asymptote/examples/RiemannSurface.asy @@ -8,6 +8,6 @@ currentprojection=orthographic(10,10,30); currentlight=(10,10,5); triple f(pair t) {return (exp(t.x)*cos(t.y),exp(t.x)*sin(t.y),t.y);} -surface s=surface(f,(-4,-2pi),(0,4pi),30,60); +surface s=surface(f,(-4,-2pi),(0,4pi),8,16,Spline); s.colors(palette(s.map(zpart),Rainbow())); -draw(s,meshpen=black); +draw(s); diff --git a/Build/source/utils/asymptote/examples/RiemannSurfaceRoot.asy b/Build/source/utils/asymptote/examples/RiemannSurfaceRoot.asy index 50cb9ead31d..93bd7035842 100644 --- a/Build/source/utils/asymptote/examples/RiemannSurfaceRoot.asy +++ b/Build/source/utils/asymptote/examples/RiemannSurfaceRoot.asy @@ -11,7 +11,7 @@ currentprojection=orthographic(10,10,30); currentlight=(10,10,5); triple f(pair t) {return (t.x*cos(t.y),t.x*sin(t.y),t.x^(1/n)*sin(t.y/n));} -surface s=surface(f,(0,0),(1,2pi*n),30,60); +surface s=surface(f,(0,0),(1,2pi*n),8,16,Spline); s.colors(palette(s.map(zpart),Rainbow())); draw(s,meshpen=black); diff --git a/Build/source/utils/asymptote/examples/animations/torusanimation.asy b/Build/source/utils/asymptote/examples/animations/torusanimation.asy index 9073ab2b56a..8370a0c25af 100644 --- a/Build/source/utils/asymptote/examples/animations/torusanimation.asy +++ b/Build/source/utils/asymptote/examples/animations/torusanimation.asy @@ -26,8 +26,11 @@ for(int i=0; i < n; ++i) { p[i]=graph(g,0,1,operator ..); } -revolution torus=revolution(shift(R*X)*Circle(O,a,Y,32),Z); -surface s=surface(torus); +triple f(pair t) { + return ((R+a*cos(t.y))*cos(t.x),(R+a*cos(t.y))*sin(t.x),a*sin(t.y)); +} + +surface s=surface(f,(0,0),(2pi,2pi),8,8,Spline); for(int i=0; i < n; ++i){ picture fig; diff --git a/Build/source/utils/asymptote/examples/condor.asy b/Build/source/utils/asymptote/examples/condor.asy index 619b4bea12b..d3b48728ea0 100644 --- a/Build/source/utils/asymptote/examples/condor.asy +++ b/Build/source/utils/asymptote/examples/condor.asy @@ -26,7 +26,7 @@ triple condor(pair t) log(d)*((-B-1)/2)); } -surface s=surface(condor,(-1,0),(1,K),64); +surface s=surface(condor,(-1,0),(1,K),16,Spline); s.colors(palette(s.map(zpart),Rainbow())); -draw(s,meshpen=black); +draw(s); diff --git a/Build/source/utils/asymptote/examples/odetest.asy b/Build/source/utils/asymptote/examples/odetest.asy new file mode 100644 index 00000000000..5dcaed21c22 --- /dev/null +++ b/Build/source/utils/asymptote/examples/odetest.asy @@ -0,0 +1,44 @@ +import ode; + +write("integration test"); +real f(real t, real x) {return cos(x);} +write(integrate(1,f,0,100,0.1,dynamic=true,0.0002,0.0004,RK3BS,verbose=true)); +write(); + +write("system integration test"); +real[] f(real t, real[] x) {return new real[] {x[1],1.5*x[0]^2};} +write(integrate(new real[] {4,-8},f,0,1,n=100,dynamic=true,tolmin=0.0002, + tolmax=0.0004,RK3BS,verbose=true)); +write(); + +write("simultaneous newton test"); +real[] function(real[] x) { + return new real[] {x[0]^2+x[1]^2-25,(x[0]-6)^2+x[1]^2-25}; +} +real[][] fJac(real[] x) { + return new real[][] {{2*x[0],2*x[1]},{2*(x[0]-6),2*x[1]}}; +} +write(newton(function,fJac,new real[] {0,-1})); +write(); + + +write("BVP solver test"); +write("Finding initial conditions that solve w''(t)=1.5*w(t), w(0)=4, w(1)=1"); +real[] initial(real[] x) { + return new real[] {4,x[0]}; +} + +real[] discrepancy(real[] x) { + write("Error: ",x[0]-1); + return new real[] {x[0]-1}; +} + +write(solveBVP(f,0,1,n=10,initial,discrepancy,guess=new real[] {-30},RK4, + iterations=10)); +write(); +write(solveBVP(f,0,1,n=100,initial,discrepancy,guess=new real[] {-30},RK4, + iterations=10)); +write(); +write(solveBVP(f,0,1,n=10000,initial,discrepancy,guess=new real[] {-30},RK4, + iterations=10)); +write(); diff --git a/Build/source/utils/asymptote/examples/p-orbital.asy b/Build/source/utils/asymptote/examples/p-orbital.asy new file mode 100644 index 00000000000..570d3f86b57 --- /dev/null +++ b/Build/source/utils/asymptote/examples/p-orbital.asy @@ -0,0 +1,28 @@ +import graph3; +import palette; +size(200); +currentprojection=orthographic(6,8,2); + +real c0=0.1; + +real f(real r) {return r*(1-r/6)*exp(-r/3);} + +triple f(pair t) { + real r=t.x; + real phi=t.y; + real f=f(r); + real s=max(min(c0/f,1),-1); + real R=r*sqrt(1-s^2); + return (R*cos(phi),R*sin(phi),r*s); +} + +bool cond(pair t) {return f(t.x) != 0;} + +real R=abs((20,20,20)); +surface s=surface(f,(0,0),(R,2pi),100,8,Spline,cond); + +s.colors(palette(s.map(abs),Gradient(palegreen,heavyblue))); +draw(s); +draw(zscale3(-1)*s); + +axes3("$x$","$y$","$z$",Arrow3); diff --git a/Build/source/utils/asymptote/examples/parametricelevation.asy b/Build/source/utils/asymptote/examples/parametricelevation.asy index 0c800f3f4ac..52cec8728a5 100644 --- a/Build/source/utils/asymptote/examples/parametricelevation.asy +++ b/Build/source/utils/asymptote/examples/parametricelevation.asy @@ -6,5 +6,5 @@ currentprojection=orthographic(4,2,4); triple f(pair z) {return expi(z.x,z.y);} -surface s=surface(f,(0,0),(pi,2pi),30); +surface s=surface(f,(0,0),(pi,2pi),10,Spline); draw(s,mean(palette(s.map(zpart),BWRainbow())),black,nolight); diff --git a/Build/source/utils/asymptote/examples/parametricsurface.asy b/Build/source/utils/asymptote/examples/parametricsurface.asy index d020bbe6e7f..6fb0272b085 100644 --- a/Build/source/utils/asymptote/examples/parametricsurface.asy +++ b/Build/source/utils/asymptote/examples/parametricsurface.asy @@ -13,10 +13,10 @@ triple f(pair t) { pen p=rgb(0.2,0.5,0.7); // surface only -//draw(surface(f,(0,0),(2pi,2pi),30,15)); +draw(surface(f,(0,0),(2pi,2pi),8,8,Spline),lightgray); // mesh only -//draw(surface(f,(0,0),(2pi,2pi),30,15),nullpen,meshpen=p); +//draw(surface(f,(0,0),(2pi,2pi),8,8,Spline),nullpen,meshpen=p); // surface & mesh -draw(surface(f,(0,0),(2pi,2pi),30,15),lightgray,meshpen=p); +//draw(surface(f,(0,0),(2pi,2pi),8,8,Spline),lightgray,meshpen=p); diff --git a/Build/source/utils/asymptote/examples/roll.asy b/Build/source/utils/asymptote/examples/roll.asy new file mode 100644 index 00000000000..088da3177f4 --- /dev/null +++ b/Build/source/utils/asymptote/examples/roll.asy @@ -0,0 +1,10 @@ +import graph3; + +size(200,0); + +triple f(pair t) { +return(t.x+t.y/4+sin(t.y),cos(t.y),sin(t.y)); +} + +surface s=surface(f,(0,0),(2pi,2pi),7,20,Spline); +draw(s,olive); diff --git a/Build/source/utils/asymptote/examples/slidedemo.asy b/Build/source/utils/asymptote/examples/slidedemo.asy index cd1f05b4124..63221ec237e 100644 --- a/Build/source/utils/asymptote/examples/slidedemo.asy +++ b/Build/source/utils/asymptote/examples/slidedemo.asy @@ -7,6 +7,7 @@ orientation=Landscape; import slide; import three; +settings.toolbar=false; viewportsize=pagewidth-2pagemargin; usersetting(); @@ -108,10 +109,8 @@ draw(pic,"$r$",(x,0,0)--(x,f(r),0),X+0.2Z,red,Arrow3); draw(pic,arc(1.1X,0.4,90,90,3,-90),Arrow3); add(pic.fit(8.5cm)); -viewportsize=viewportmargin=0; title("\mbox{Asymptote: 2D \& 3D Vector Graphics Language}"); asyinclude("logo3"); -skip(); center("\tt http://asymptote.sf.net"); center("(freely available under the GNU public license)"); diff --git a/Build/source/utils/asymptote/examples/soccerball.asy b/Build/source/utils/asymptote/examples/soccerball.asy new file mode 100644 index 00000000000..46f626bc6b9 --- /dev/null +++ b/Build/source/utils/asymptote/examples/soccerball.asy @@ -0,0 +1,87 @@ +import graph3; +size(400); +currentlight.background=palegreen+opacity(0.2); + +linegranularity=1; + +real c=(1+sqrt(5))/2; + +triple[] z={(c,1,0),(-c,1,0),(-c,-1,0),(c,-1,0)}; +triple[] x={(0,c,1),(0,-c,1),(0,-c,-1),(0,c,-1)}; +triple[] y={(1,0,c),(1,0,-c),(-1,0,-c),(-1,0,c)}; + +triple[][] Q={ + {z[0],y[1],x[3],x[0],y[0],z[3]}, + {z[1],x[0],x[3],y[2],z[2],y[3]}, + {z[2],z[1],y[2],x[2],x[1],y[3]}, + {z[3],z[0],y[0],x[1],x[2],y[1]}, + {x[0],x[3],z[1],y[3],y[0],z[0]}, + {x[1],x[2],z[2],y[3],y[0],z[3]}, + {x[2],x[1],z[3],y[1],y[2],z[2]}, + {x[3],x[0],z[0],y[1],y[2],z[1]}, + {y[0],y[3],x[1],z[3],z[0],x[0]}, + {y[1],y[2],x[2],z[3],z[0],x[3]}, + {y[2],y[1],x[3],z[1],z[2],x[2]}, + {y[3],y[0],x[0],z[1],z[2],x[1]} +}; + +path3 p=arc(O,Q[0][0],Q[0][1]); +real R=abs(point(p,reltime(p,1/3))); + +triple[][] P; +for(int i=0; i < Q.length; ++i){ + P[i]=new triple[] ; + for(int j=0; j < Q[i].length; ++j){ + P[i][j]=Q[i][j]/R; + } +} + +surface sphericaltriangle(triple center, triple A, triple B, triple C, + int nu=3, int nv=nu) { + path3 tri1=arc(center,A,B); + path3 tri2=arc(center,A,C); + path3 tri3=arc(center,B,C); + triple tri(pair p) { + path3 cr=arc(O,relpoint(tri2,p.x),relpoint(tri3,p.x)); + return relpoint(cr,p.y); + }; + + return surface(tri,(0,0),(1-sqrtEpsilon,1),nu,nv,Spline); +} + +for(int i=0; i < P.length; ++i){ + triple[] pentagon=sequence(new triple(int k) { + path3 p=arc(O,P[i][0],P[i][k+1]); + return point(p,reltime(p,1/3)); + },5); + pentagon.cyclic(true); + draw(sequence(new path3(int k) { + return arc(O,pentagon[k],pentagon[k+1]);},5),linewidth(2pt)); + triple M=unit(sum(pentagon)/5); + for(int i=0; i < 5; ++i){ + surface sf=sphericaltriangle(O,pentagon[i],M,pentagon[i+1]); + draw(sf,black); + } +} + +for(int i=0; i < P.length; ++i){ + for(int j=1; j <= 5; ++j){ + triple K=P[i][0]; + triple A=P[i][j]; + triple B=P[i][(j % 5)+1]; + path3[] p={arc(O,K,A),arc(O,A,B),arc(O,B,K)}; + draw(subpath(p[0],reltime(p[0],1/3),reltime(p[0],2/3)),linewidth(4pt)); + triple[] hexagon={point(p[0],reltime(p[0],1/3)), + point(p[0],reltime(p[0],2/3)), + point(p[1],reltime(p[1],1/3)), + point(p[1],reltime(p[1],2/3)), + point(p[2],reltime(p[2],1/3)), + point(p[2],reltime(p[2],2/3))}; + hexagon.cyclic(true); + triple M=unit(sum(hexagon)/6); + for(int i=0; i < 6; ++i){ + surface sf=sphericaltriangle(O,hexagon[i],M,hexagon[i+1]); + draw(sf,white); + } + } +} diff --git a/Build/source/utils/asymptote/examples/sphericalharmonic.asy b/Build/source/utils/asymptote/examples/sphericalharmonic.asy index 471bcaae9cd..1df89959f33 100644 --- a/Build/source/utils/asymptote/examples/sphericalharmonic.asy +++ b/Build/source/utils/asymptote/examples/sphericalharmonic.asy @@ -8,5 +8,6 @@ real r(real theta, real phi) {return 1+0.5*(sin(2*theta)*sin(2*phi))^2;} triple f(pair z) {return r(z.x,z.y)*expi(z.x,z.y);} -surface s=surface(f,(0,0),(pi,2pi),50); -draw(s,mean(palette(s.map(abs),Gradient(yellow,red))),nolight); +surface s=surface(f,(0,0),(pi,2pi),50,Spline); +s.colors(palette(s.map(abs),Gradient(yellow,red))); +draw(s); diff --git a/Build/source/utils/asymptote/examples/torus.asy b/Build/source/utils/asymptote/examples/torus.asy index 33d6e6ddb1a..e2363f47450 100644 --- a/Build/source/utils/asymptote/examples/torus.asy +++ b/Build/source/utils/asymptote/examples/torus.asy @@ -1,7 +1,17 @@ size(200); -import solids; +import graph3; currentprojection=perspective(5,4,4); -revolution torus=revolution(shift(3X)*Circle(O,1,Y,32),Z,90,345); -draw(surface(torus),green); +//import solids; +//revolution torus=revolution(shift(3X)*Circle(O,1,Y,32),Z,90,345); +//draw(surface(torus),green); + +real R=3; +real a=1; + +triple f(pair t) { + return ((R+a*cos(t.y))*cos(t.x),(R+a*cos(t.y))*sin(t.x),a*sin(t.y)); +} + +draw(surface(f,(radians(90),0),(radians(345),2pi),8,8,Spline),green); diff --git a/Build/source/utils/asymptote/examples/trumpet.asy b/Build/source/utils/asymptote/examples/trumpet.asy new file mode 100644 index 00000000000..8d48da0c951 --- /dev/null +++ b/Build/source/utils/asymptote/examples/trumpet.asy @@ -0,0 +1,10 @@ +import graph3; +size(200,0); + +triple f(pair t) { + return(10*sin(t.y),cos(t.x)*(cos(t.y)+log(abs(tan(t.y/2)))), + sin(t.x)*(cos(t.y)+log(abs(tan(t.y/2))))); +} + +surface s=surface(f,(0,pi/2),(2pi,pi-0.1),7,15,Spline); +draw(s,olive); diff --git a/Build/source/utils/asymptote/examples/twistedtubes.asy b/Build/source/utils/asymptote/examples/twistedtubes.asy index 420e3898986..4d38d86f4df 100644 --- a/Build/source/utils/asymptote/examples/twistedtubes.asy +++ b/Build/source/utils/asymptote/examples/twistedtubes.asy @@ -11,10 +11,10 @@ triple f2(pair t) {return (cos(t.x)+2cos(w*t.y),sin(t.x)+2sin(w*t.y),t.y);} triple f3(pair t) {return (cos(t.x)+2sin(w*t.y),sin(t.x)-2cos(w*t.y),t.y);} triple f4(pair t) {return (cos(t.x)-2sin(w*t.y),sin(t.x)+2cos(w*t.y),t.y);} -surface s1=surface(f1,(0,0),(2pi,10),25,15); -surface s2=surface(f2,(0,0),(2pi,10),25,15); -surface s3=surface(f3,(0,0),(2pi,10),25,15); -surface s4=surface(f4,(0,0),(2pi,10),25,15); +surface s1=surface(f1,(0,0),(2pi,10),8,8,Spline); +surface s2=surface(f2,(0,0),(2pi,10),8,8,Spline); +surface s3=surface(f3,(0,0),(2pi,10),8,8,Spline); +surface s4=surface(f4,(0,0),(2pi,10),8,8,Spline); pen[] Rainbow=Rainbow(); s1.colors(palette(s1.map(f),Rainbow)); @@ -22,7 +22,7 @@ s2.colors(palette(s2.map(f),Rainbow)); s3.colors(palette(s3.map(f),Rainbow)); s4.colors(palette(s4.map(f),Rainbow)); -draw(s1,meshpen=black); -draw(s2,meshpen=black); -draw(s3,meshpen=black); -draw(s4,meshpen=black); +draw(s1); +draw(s2); +draw(s3); +draw(s4); diff --git a/Build/source/utils/asymptote/examples/xxsq01y.asy b/Build/source/utils/asymptote/examples/xxsq01y.asy index 14cf177256e..53f77d1f9bb 100644 --- a/Build/source/utils/asymptote/examples/xxsq01y.asy +++ b/Build/source/utils/asymptote/examples/xxsq01y.asy @@ -1,6 +1,6 @@ import solids; size(0,150); -currentprojection=perspective(0,0,10); +currentprojection=perspective(0,0,10,up=Y); pen color=green; real alpha=240; |