diff options
Diffstat (limited to 'Master/texmf-dist/doc/asymptote/examples/animations/wheel.asy')
-rw-r--r-- | Master/texmf-dist/doc/asymptote/examples/animations/wheel.asy | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/asymptote/examples/animations/wheel.asy b/Master/texmf-dist/doc/asymptote/examples/animations/wheel.asy new file mode 100644 index 00000000000..6620d590850 --- /dev/null +++ b/Master/texmf-dist/doc/asymptote/examples/animations/wheel.asy @@ -0,0 +1,63 @@ +import graph; + +// Uncomment the following 2 lines to support pdf animations: +// usepackage("animate"); +// settings.tex="pdflatex"; + +import animation; + +size(0,200); + +defaultpen(3); +dotfactor=4; + +pair wheelpoint(real t) +{ + return (t+cos(t),-sin(t)); +} + +guide wheel(guide g=nullpath, real a, real b, int n) +{ + real width=(b-a)/n; + for(int i=0; i <= n; ++i) { + real t=a+width*i; + g=g--wheelpoint(t); + } + return g; +} + +real t1=0; +real t2=t1+2*pi; + +animation a; + +draw(circle((0,0),1)); +draw(wheel(t1,t2,100),linetype("0 2")); +yequals(Label("$y=-1$",1.0),-1,extend=true,linetype("4 4")); +xaxis(Label("$x$",align=3SW),0); +yaxis("$y$",0,1.2); +pair z1=wheelpoint(t1); +pair z2=wheelpoint(t2); +dot(z1); +dot(z2); + +int n=10; +real dt=(t2-t1)/n; +for(int i=0; i <= n; ++i) { + save(); + + real t=t1+dt*i; + draw(circle((t,0),1),red); + dot(wheelpoint(t)); + + a.add(); // Add currentpicture to animation. + restore(); +} + +erase(); + +// Merge the images into a gif animation. +a.movie(BBox(0.25cm),loops=10,delay=250); + +// Merge the images into a pdf animation. +// label(a.pdf(BBox(0.25cm),delay=250,"controls",multipage=false)); |