diff options
Diffstat (limited to 'Master/texmf-dist/doc/asymptote/examples')
6 files changed, 191 insertions, 137 deletions
diff --git a/Master/texmf-dist/doc/asymptote/examples/CAD1.asy b/Master/texmf-dist/doc/asymptote/examples/CAD1.asy index 4602e73b709..26184aaad2c 100644 --- a/Master/texmf-dist/doc/asymptote/examples/CAD1.asy +++ b/Master/texmf-dist/doc/asymptote/examples/CAD1.asy @@ -1,43 +1,43 @@ -import CAD;
-
-sCAD cad=sCAD.Create();
-
-// Freehand line
-draw(g=cad.MakeFreehand(pFrom=(3,-1)*cm,(6,-1)*cm),
- p=cad.pFreehand);
-
-// Standard measurement lines
-draw(g=box((0,0)*cm,(1,1)*cm),p=cad.pVisibleEdge);
-cad.MeasureParallel(L="$\sqrt{2}$",
- pFrom=(0,1)*cm,
- pTo=(1,0)*cm,
- dblDistance=-15mm);
-
-// Label inside,shifted to the right; arrows outside
-draw(g=box((2,0)*cm,(3,1)*cm),p=cad.pVisibleEdge);
-cad.MeasureParallel(L="1",
- pFrom=(2,1)*cm,
- pTo=(3,1)*cm,
- dblDistance=5mm,
- dblLeft=5mm,
- dblRelPosition=0.75);
-
-// Label and arrows outside
-draw(g=box((5,0)*cm,(5.5,1)*cm),p=cad.pVisibleEdge);
-cad.MeasureParallel(L="0.5",
- pFrom=(5,1)*cm,
- pTo=(5.5,1)*cm,
- dblDistance=5mm,
- dblLeft=10mm,
- dblRelPosition=-1);
-
-// Small bounds,asymmetric measurement line
-draw(g=box((7,0)*cm,(7.5,1)*cm),p=cad.pVisibleEdge);
-cad.MeasureParallel(L="0.5",
- pFrom=(7,1)*cm,
- pTo=(7.5,1)*cm,
- dblDistance=5mm,
- dblLeft=2*cad.GetMeasurementBoundSize(bSmallBound=true),
- dblRight=10mm,
- dblRelPosition=2,
- bSmallBound=true);
+import CAD; + +sCAD cad=sCAD.Create(); + +// Freehand line +draw(g=cad.MakeFreehand(pFrom=(3,-1)*cm,(6,-1)*cm), + p=cad.pFreehand); + +// Standard measurement lines +draw(g=box((0,0)*cm,(1,1)*cm),p=cad.pVisibleEdge); +cad.MeasureParallel(L="$\sqrt{2}$", + pFrom=(0,1)*cm, + pTo=(1,0)*cm, + dblDistance=-15mm); + +// Label inside,shifted to the right; arrows outside +draw(g=box((2,0)*cm,(3,1)*cm),p=cad.pVisibleEdge); +cad.MeasureParallel(L="1", + pFrom=(2,1)*cm, + pTo=(3,1)*cm, + dblDistance=5mm, + dblLeft=5mm, + dblRelPosition=0.75); + +// Label and arrows outside +draw(g=box((5,0)*cm,(5.5,1)*cm),p=cad.pVisibleEdge); +cad.MeasureParallel(L="0.5", + pFrom=(5,1)*cm, + pTo=(5.5,1)*cm, + dblDistance=5mm, + dblLeft=10mm, + dblRelPosition=-1); + +// Small bounds,asymmetric measurement line +draw(g=box((7,0)*cm,(7.5,1)*cm),p=cad.pVisibleEdge); +cad.MeasureParallel(L="0.5", + pFrom=(7,1)*cm, + pTo=(7.5,1)*cm, + dblDistance=5mm, + dblLeft=2*cad.GetMeasurementBoundSize(bSmallBound=true), + dblRight=10mm, + dblRelPosition=2, + bSmallBound=true); diff --git a/Master/texmf-dist/doc/asymptote/examples/RiemannSphere.asy b/Master/texmf-dist/doc/asymptote/examples/RiemannSphere.asy new file mode 100644 index 00000000000..ec1ab7586a9 --- /dev/null +++ b/Master/texmf-dist/doc/asymptote/examples/RiemannSphere.asy @@ -0,0 +1,47 @@ +import graph3; +import solids; + +currentlight=White; +defaultrender.merge=true; + +size(10cm,0); + +pair k=(1,0.2); +real r=abs(k); +real theta=angle(k); + +real x(real t) { return r^t*cos(t*theta); } +real y(real t) { return r^t*sin(t*theta); } +real z(real t) { return 0; } + +real u(real t) { return x(t)/(x(t)^2+y(t)^2+1); } +real v(real t) { return y(t)/(x(t)^2+y(t)^2+1); } +real w(real t) { return (x(t)^2+y(t)^2)/(x(t)^2+y(t)^2+1); } + +real nb=3; +for (int i=0; i<12; ++i) draw((0,0,0)--nb*(Cos(i*30),Sin(i*30),0),yellow); +for (int i=0; i<=nb; ++i) draw(circle((0,0,0),i),lightgreen+white); + + +path3 p=graph(x,y,z,-200,40,operator ..); +path3 q=graph(u,v,w,-200,40,operator ..); + +revolution sph=sphere((0,0,0.5),0.5); +draw(surface(sph),green+white+opacity(0.5)); + +draw(p,1bp+heavyred); +draw(q,1bp+heavyblue); + +triple + A=(0,0,1), + B=(u(40),v(40),w(40)), + C=(x(40),y(40),z(40)); + +path3 L=A--C; +draw(L,1bp+black); + +pen p=fontsize(8pt); + +dot("$(0,0,1)$",A,N,p); +dot("$(u,v,w)$",B,E,p); +dot("$(x,y,0)$",C,E,p); diff --git a/Master/texmf-dist/doc/asymptote/examples/circumcircle.asy b/Master/texmf-dist/doc/asymptote/examples/circumcircle.asy new file mode 100644 index 00000000000..96b3bdd82a0 --- /dev/null +++ b/Master/texmf-dist/doc/asymptote/examples/circumcircle.asy @@ -0,0 +1,9 @@ +unitsize(1inch); + +path tri=(0,0)--(1,0)--(2,1)--cycle; +pair p1=point(tri,0.5); +pair p2=point(tri,1.5); +pair z0=extension(p1,p1+I*dir(tri,0.5),p2,p2+I*dir(tri,1.5)); +dot(z0); +draw(circle(z0,abs(z0-point(tri,0)))); +draw(tri,red); diff --git a/Master/texmf-dist/doc/asymptote/examples/externalprc.tex b/Master/texmf-dist/doc/asymptote/examples/externalprc.tex index e6d4ade1dcf..d131eebd426 100644 --- a/Master/texmf-dist/doc/asymptote/examples/externalprc.tex +++ b/Master/texmf-dist/doc/asymptote/examples/externalprc.tex @@ -1,12 +1,13 @@ % Generate inline PRC images for latex with -% asy -inlineimage teapot -render=4 +% asy -inlineimage cube -render=4 % % Generate inline PRC images for pdflatex with -% asy -inlineimage teapot -render=4 -tex pdflatex +% asy -inlineimage cube -render=4 -tex pdflatex % \documentclass[12pt]{article} -\input teapot.pre +\input cube.pre +\usepackage[bigfiles,noplaybutton]{media9} \RequirePackage{color,graphicx} \begin{document} -\input teapot.tex +\input cube.tex \end{document} diff --git a/Master/texmf-dist/doc/asymptote/examples/sqrtx01y1.asy b/Master/texmf-dist/doc/asymptote/examples/sqrtx01y1.asy index dcb247f572e..0bb7dd52162 100644 --- a/Master/texmf-dist/doc/asymptote/examples/sqrtx01y1.asy +++ b/Master/texmf-dist/doc/asymptote/examples/sqrtx01y1.asy @@ -15,9 +15,6 @@ revolution a=revolution(p3,Y,0,360); draw(surface(a),green,render(compression=Low,merge=true)); draw(p3,blue); -xtick((0,0,0)); -xtick((1,0,0)); - xaxis3(Label("$x$",1),Arrow3); yaxis3(Label("$y$",1),ymax=1.5,dashed,Arrow3); dot(Label("$(1,1)$"),(1,1,0)); diff --git a/Master/texmf-dist/doc/asymptote/examples/worldmap.asy b/Master/texmf-dist/doc/asymptote/examples/worldmap.asy index 59479fffbe2..c52ff23dedc 100644 --- a/Master/texmf-dist/doc/asymptote/examples/worldmap.asy +++ b/Master/texmf-dist/doc/asymptote/examples/worldmap.asy @@ -1,87 +1,87 @@ -settings.outformat="pdf";
-size(20cm);
-
-// The required data file is available here:
-// http://www.uni-graz.at/~schwaige/asymptote/worldmap.dat
-// This data was originally obtained from
-// http://www.ngdc.noaa.gov/mgg_coastline/mapit.jsp
-
-real findtheta(real phi, real epsilon=realEpsilon) {
- // Determine for given phi the unique solution -pi/2 <= theta <= pi/2 off
- // 2*theta+sin(2*theta)=pi*sin(phi)
- // in the non-trivial cases by Newton iteration;
- // theoretically the initial guess pi*sin(phi)/4 always works.
- real nwtn(real x, real y) {return x-(2x+sin(2x)-y)/(2+2*cos(2x));};
- real y=pi*sin(phi);
- if(y == 0) return 0.0;
- if(abs(y) == 1) return pi/2;
- real startv=y/4;
- real endv=nwtn(startv,y);
- if(epsilon < 500*realEpsilon) epsilon=500*realEpsilon;
- while(abs(endv-startv) > epsilon) {startv=endv; endv=nwtn(startv,y);};
- return endv;
-}
-
-pair mollweide(real lambda, real phi, real lambda0=0){
- // calculate the Mollweide projection centered at lambda0 for the point
- // with coordinates(phi,lambda)
- static real c1=2*sqrt(2)/pi;
- static real c2=sqrt(2);
- real theta=findtheta(phi);
- return(c1*(lambda-lambda0)*cos(theta), c2*sin(theta));
-}
-
-guide gfrompairs(pair[] data){
- guide gtmp;
- for(int i=0; i < data.length; ++i) {
- pair tmp=mollweide(radians(data[i].y),radians(data[i].x));
- gtmp=gtmp--tmp;
- }
- return gtmp;
-}
-
-string datafile="worldmap.dat";
-
-file in=input(datafile,comment="/").line();
-// new commentchar since "#" is contained in the file
-pair[][] arrarrpair=new pair[][] ;
-int cnt=-1;
-bool newseg=false;
-while(true) {
- if(eof(in)) break;
- string str=in;
- string[] spstr=split(str,"");
-
- if(spstr[0] == "#") {++cnt; arrarrpair[cnt]=new pair[] ; newseg=true;}
- if(spstr[0] != "#" && newseg) {
- string[] spstr1=split(str,'\t'); // separator is TAB not SPACE
- pair tmp=((real) spstr1[1],(real) spstr1[0]);
- arrarrpair[cnt].push(tmp);
- }
-}
-
-for(int i=0; i < arrarrpair.length; ++i)
- draw(gfrompairs(arrarrpair[i]),1bp+black);
-
-// lines of longitude and latitude
-pair[] constlong(real lambda, int np=100) {
- pair[] tmp;
- for(int i=0; i <= np; ++i) tmp.push((-90+i*180/np,lambda));
- return tmp;
-}
-
-pair[] constlat(real phi, int np=100) {
- pair[] tmp;
- for(int i=0; i <= 2*np; ++i) tmp.push((phi,-180+i*180/np));
- return tmp;
-}
-
-for(int j=1; j <= 5; ++j) draw(gfrompairs(constlong(-180+j/6*360)),white);
-draw(gfrompairs(constlong(-180)),1.5bp+white);
-draw(gfrompairs(constlong(180)),1.5bp+white);
-for(int j=0; j <= 12; ++j) draw(gfrompairs(constlat(-90+j/6*180)),white);
-//draw(gfrompairs(constlong(10)),dotted);
-
-close(in);
-shipout(bbox(1mm,darkblue,Fill(lightblue)), view=true);
-
+settings.outformat="pdf"; +size(20cm); + +// The required data file is available here: +// http://www.uni-graz.at/~schwaige/asymptote/worldmap.dat +// This data was originally obtained from +// http://www.ngdc.noaa.gov/mgg_coastline/mapit.jsp + +real findtheta(real phi, real epsilon=realEpsilon) { + // Determine for given phi the unique solution -pi/2 <= theta <= pi/2 off + // 2*theta+sin(2*theta)=pi*sin(phi) + // in the non-trivial cases by Newton iteration; + // theoretically the initial guess pi*sin(phi)/4 always works. + real nwtn(real x, real y) {return x-(2x+sin(2x)-y)/(2+2*cos(2x));}; + real y=pi*sin(phi); + if(y == 0) return 0.0; + if(abs(y) == 1) return pi/2; + real startv=y/4; + real endv=nwtn(startv,y); + if(epsilon < 500*realEpsilon) epsilon=500*realEpsilon; + while(abs(endv-startv) > epsilon) {startv=endv; endv=nwtn(startv,y);}; + return endv; +} + +pair mollweide(real lambda, real phi, real lambda0=0){ + // calculate the Mollweide projection centered at lambda0 for the point + // with coordinates(phi,lambda) + static real c1=2*sqrt(2)/pi; + static real c2=sqrt(2); + real theta=findtheta(phi); + return(c1*(lambda-lambda0)*cos(theta), c2*sin(theta)); +} + +guide gfrompairs(pair[] data){ + guide gtmp; + for(int i=0; i < data.length; ++i) { + pair tmp=mollweide(radians(data[i].y),radians(data[i].x)); + gtmp=gtmp--tmp; + } + return gtmp; +} + +string datafile="worldmap.dat"; + +file in=input(datafile,comment="/").line(); +// new commentchar since "#" is contained in the file +pair[][] arrarrpair=new pair[][] ; +int cnt=-1; +bool newseg=false; +while(true) { + if(eof(in)) break; + string str=in; + string[] spstr=split(str,""); + + if(spstr[0] == "#") {++cnt; arrarrpair[cnt]=new pair[] ; newseg=true;} + if(spstr[0] != "#" && newseg) { + string[] spstr1=split(str,'\t'); // separator is TAB not SPACE + pair tmp=((real) spstr1[1],(real) spstr1[0]); + arrarrpair[cnt].push(tmp); + } +} + +for(int i=0; i < arrarrpair.length; ++i) + draw(gfrompairs(arrarrpair[i]),1bp+black); + +// lines of longitude and latitude +pair[] constlong(real lambda, int np=100) { + pair[] tmp; + for(int i=0; i <= np; ++i) tmp.push((-90+i*180/np,lambda)); + return tmp; +} + +pair[] constlat(real phi, int np=100) { + pair[] tmp; + for(int i=0; i <= 2*np; ++i) tmp.push((phi,-180+i*180/np)); + return tmp; +} + +for(int j=1; j <= 5; ++j) draw(gfrompairs(constlong(-180+j/6*360)),white); +draw(gfrompairs(constlong(-180)),1.5bp+white); +draw(gfrompairs(constlong(180)),1.5bp+white); +for(int j=0; j <= 12; ++j) draw(gfrompairs(constlat(-90+j/6*180)),white); +//draw(gfrompairs(constlong(10)),dotted); + +close(in); +shipout(bbox(1mm,darkblue,Fill(lightblue)), view=true); + |