Animation with Asymptote – fig0010

Category: Animation,AsymptotePh. Ivaldi @ 8 h 20 min

Figure 0001
(Compiled with Asymptote version 1.43)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import contour3;
import animate;
// settings.tex="pdflatex";
// settings.outformat="pdf";

size(10cm);
currentprojection=orthographic(15,8,10);
animation A;
A.global=false;

typedef real fct3(real,real,real);
fct3 F(real t)
{
  return new real(real x, real y, real z){return x^2+y^2-t*z^2+t-1;};
}

int n=15;
picture pic;
real tmin=0.1, tmax=2;
real step=(tmax-tmin)/n;
draw(box((-5,-5,-5),(5,5,5)));
for (int i=0; i < n; ++i) {
  save();
  draw(surface(contour3(F(tmin+i*step),(-5,-5,-5),(5,5,5),15)),lightblue);
  pic.erase();
  add(pic,bbox(5mm,FillDraw(lightyellow)));
  A.add(pic);
  restore();
}

A.movie();

Étiquettes : , , ,


Animation with Asymptote – fig0020

Category: Animation,AsymptotePh. Ivaldi @ 9 h 20 min

Figure 0002
(Compiled with Asymptote version 1.43)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import geometry;
import animate;
settings.tex="pdflatex";

animation A;
size(12cm);

for (int a=1; a < 20; ++a) {
  save();
  point P=(-4.5,0); dot(P);
  inversion inv=inversion(1,P);
  line l1=line((0,0),(-0.35,1)), l2=line((0,0),(0.35,1));
  path g1=inv*l1, g2=inv*l2;
  fill(g1^^g2,evenodd+lightgrey); draw(g1,linewidth(bp));
  draw(g2,linewidth(bp));

  for (int i:new int[]{-1,1}) {
    point P=(0,3i/a);
    triangle t=triangle(shift(P)*hline,l1,l2);
    int n=a;
    for (int j=0; j <= n; ++j) {
      circle C=excircle(t.AB);
      t=triangle(shift(angpoint(C,i*90))*hline,l1,l2);
      circle Cp=inv*C;
      path g=Cp;
      fill(g,0.95*yellow);
      draw(g,bp+red); draw(g,blue);
    }
  }
  picture pic;
  add(pic,bbox(5mm,Fill(rgb(0.95,0.95,0.8))));
  A.add(pic);
  restore();
}

A.pdf(keep=true);

Étiquettes : , ,


Animation with Asymptote – fig0030

Category: Animation,AsymptotePh. Ivaldi @ 10 h 20 min

Figure 0003
(Compiled with Asymptote version 1.43)
This animation is available in the Syracuse web site.
    
import geometry;
import animate;
animation A;

size(15cm);

int nAnim=75;
int nCircle=6;
real astep=360/nAnim;

inversion inv=inversion((-1,-2),1);
line L1=line(N,S);
circle C=inv*L1;
point center=C.C;

for (int i=-nAnim; i < nAnim; ++i) {
  real r;
  r=0.001+4*(i/nAnim)^2;
  line L2=shift(2*r*E)*L1;
  transform T=shift(0,-2*r);
  transform R=rotate(astep*i,center);
  circle C0=circle(r*E+nCircle/2*sqrt(r)*N,r);
  circle[] Ci=sequence(new circle(int i){return T^i*C0;}, nCircle);

  fill(R*(path)C, 0.3*blue);
  circle Cl=R*(inv*L2);
  transform dsh=shift(Cl.r/3*unit(center-Cl.C));
  radialshade((path)Cl,white,dsh*Cl.C,0,black,dsh*Cl.C,Cl.r);
  for (int i=0; i < Ci.length; ++i) {
    circle Ct=inv*Ci[i];
    transform dsh=shift(Ct.r/3*unit(center-Ct.C));
    radialshade(R*(path)Ct,red,dsh*R*Ct.C,0,black,dsh*R*Ct.C,Ct.r);
  }
  A.add();
  erase();
}

A.movie(BBox(2mm,Fill(black)));

Étiquettes : , ,


Animation with Asymptote – fig0040

Category: Animation,AsymptotePh. Ivaldi @ 11 h 20 min

Figure 0004
(Compiled with Asymptote version 1.43)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import geometry;
import animate;
settings.tex="pdflatex";
settings.outformat="pdf";

animation Anim;

size(10cm,0);

circle C=circle(origin,1);
draw(C);
point A=point(C,0), B, M;
guide locus;


for (real a=0.001; a < 360; a += 5) {
  save();
  B=angpoint(C,a);
  triangle t=triangle(origin,A,B);
  draw(t);
  draw(incircle(t), bp+0.8*blue);
  triangle intouch=intouch(t);
  draw(intouch, dot);
  M=intouch(t.AC);
  label("$N$", Label("$M$", 0.8*red), "$P$", intouch);
  dot(M, 0.8*red);
  locus=locus..M;
  draw(locus, bp+0.8*red);
  Anim.add();
  restore();
}

// Anim.movie();
Anim.pdf(keep=true);


Étiquettes : , , , ,


Animation with Asymptote – fig0050

Category: Animation,AsymptotePh. Ivaldi @ 12 h 20 min

Figure 0005
(Compiled with Asymptote version 1.43)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
/* Author: Nathan Carter. */
include "./makecd.asy";
import animate;
// settings.tex="pdflatex";
settings.keep=true;

animation A;
A.global=false;

real length = 4; // seconds
int fps = 50;
real rad = 6;
real ht = 2;
real pixsz = 300;
real ptsz = 1;
int loops = 6;
pen border = black;

real frames = length*fps;
picture tmp;

size(pixsz);
for (int i=100 ; i < 100+frames ; ++i) {
  save();
  add(CayleyDiagram(nodeLocs, arrows, orders, arrowPens,
                    cam = (rad*cos(2*i*pi/frames),rad*sin(2*i*pi/frames),ht),
                    arrowThickness = 2, nodeSize = 0.02,
                    arrowMargin = 1mm, depthCueing = true ));
  draw(box((-ptsz/2,-ptsz/2), (ptsz/2,ptsz/2)), border);
  A.add();
  write( "Did " + (string)(i-99) + " out of " + (string)frames );
  restore();
}

write( "Merging..." );
A.movie(delay=(int)(100/fps));
write( "Done." );

Étiquettes : ,


Animation with Asymptote – fig0060

Category: Animation,AsymptotePh. Ivaldi @ 13 h 20 min

Figure 0006
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
//Author Jens Schwaiger.
import polyhedron_js;
import animate;
settings.render=0;
settings.tex="pdflatex";
settings.outformat="pdf";

size(16cm);
currentprojection=perspective(5,4,2);
currentlight=(5,4,2);

polyhedron Plane;
Plane[0]=(-2,-2,-1.5)--(2.5,-2,-1.5)--(2.5,2.5,-1.5)--(-2,2.5,-1.5)--cycle;
Plane[1]=(-2,-2,-1.5)--(-2,2.5,-1.5)--(-2,2.5,0)--(-2,-2,0)--cycle;

int n=180;
pen[] drawcol={black+1bp};
pen[] fcol1={0.8*red,0.8*blue,0.8*green,orange,heavycyan,gray};

animation anim;

triple[] posofsolids;
real angle;
for(int janim=0; janim < n; ++janim){
  for(int i=0; i < 5; ++i) {
    angle=2pi/5*i+2pi*janim/n;
    posofsolids[i]=(1.7*cos(angle)+1,1.7*sin(angle)+1,0);
  }
  transform3 T=rotate(-degrees(2*angle),Z);
  polyhedron[] parr={ shift(posofsolids[0])*T*icosahedron,
                      shift(posofsolids[1])*T*dodecahedron,
                      shift(posofsolids[2])*T*cube,
                      shift(posofsolids[3])*T*rotate(45,Z)*octahedron,
                      shift(posofsolids[4])*T*rotate(90,Z)*tetrahedron,
                      Plane };

  save();
  filldraw(parr,fcol=fcol1,dcol=drawcol,op=0.9);
  anim.add();
  restore();
}

anim.movie(BBox(3mm,darkblue+3bp+miterjoin,FillDraw(paleblue)));

Étiquettes : , ,


Animation with Asymptote – fig0070

Category: Animation,AsymptotePh. Ivaldi @ 14 h 20 min

Figure 0007
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import polyhedron_js;
import animation;

settings.tex="pdflatex";
settings.outformat="pdf"; // for opacity
settings.render=0;

animation A;
size(8cm);

// currentprojection=perspective(7,6,4); //if you want perspectivic look
currentprojection=orthographic(1,0.5,1); //if you want othographic look
currentlight=(1,1,2);
// currentlight=nolight;

int col=0;
pen[] fcol={palegreen+paleblue+lightgrey};
fcol.cyclic=true;

polyhedron[] parr;

for (int i=0; i < 360; i += 2) {
  parr[0]=rotate(i,Z)*rhombicosDodec;
  save();
  filldraw(parr,fcol,op=0.9);
  A.add();
  restore();
}

A.movie();

Étiquettes : , ,


Animation with Asymptote – fig0080

Category: Animation,AsymptotePh. Ivaldi @ 15 h 20 min

Figure 0008
(Compiled with Asymptote version 1.86svn-r4626)
This animation is available in the Syracuse web site.
    
import graph3;
import animation;
import solids;

settings.render=0;
animation A;
A.global=false;

int nbpts=500;
real q=2/5;
real pas=5*2*pi/nbpts;
int angle=3;
real R=3;

unitsize(1cm);

real x(real t){return R*cos(q*t)*cos(t);}
real y(real t){return R*cos(q*t)*sin(t);}
real z(real t){return R*sin(q*t);}

triple[] P;
real t=-pi;
for (int i=0; i<nbpts; ++i) {
  t+=pas;
  P.push((x(t),y(t),z(t)));
}

currentprojection=orthographic((0,5,2));
currentlight=(3,3,5);

pen p=rgb(0.1,0.1,0.58);
transform3 t=rotate(angle,(0,0,0),(1,0.25,0.25));

filldraw(box((-R-0.5,-R-0.5),(R+0.5,R+0.5)), p, 3mm+black+miterjoin);

revolution r=sphere(O,R);
draw(surface(r),p);

for (int phi=0; phi<360; phi+=angle) {
  bool[] back,front;
  save();

  for (int i=0; i<nbpts; ++i) {
    P[i]=t*P[i];
    bool test=dot(P[i],currentprojection.camera) > 0;
    front.push(test);
  }

  draw(segment(P,front,operator ..),linewidth(1mm));
  draw(segment(P,!front,operator ..),grey);
  A.add();
  restore();
}

A.movie(options="-density 350 -resample 96 -quality 100 -depth 8 -strip");

Étiquettes : , , , , , ,


Animation with Asymptote – fig0090

Category: Animation,AsymptotePh. Ivaldi @ 16 h 20 min

Figure 0009
(Compiled with Asymptote version 1.86svn-r4626)
    
size(0,10cm);
import graph3;
import animation;
import solids;

currentlight.background=black;
settings.render=0;
animation A;
A.global=false;

int nbpts=500;
real q=2/5;
real pas=5*2*pi/nbpts;
int angle=4;
real R=0.5;
pen p=rgb(0.1,0.1,0.58);
triple center=(1,1,1);
transform3 T=rotate(angle,center,center+X+0.25*Y+0.3*Z);

real x(real t){return center.x+R*cos(q*t)*cos(t);}
real y(real t){return center.y+R*cos(q*t)*sin(t);}
real z(real t){return center.z+R*sin(q*t);}

currentprojection=orthographic(1,1,1);
currentlight=(0,center.y-0.5,2*(center.z+R));

triple U=(center.x+1.1*R,0,0), V=(0,center.y+1.1*R,0);
path3 xy=plane(U,V,(0,0,0));
path3 xz=rotate(90,X)*xy;
path3 yz=rotate(-90,Y)*xy;

triple[] P;
path3 curve;
real t=-pi;
for (int i=0; i < nbpts; ++i) {
  t+=pas;
  triple M=(x(t),y(t),z(t));
  P.push(M);
  curve = curve..M;
}

curve=curve..cycle;

draw(surface(xy), grey);
draw(surface(xz), grey);
draw(surface(yz), grey);

triple xyc=(center.x,center.y,0);
path3 cle=shift(xyc)*scale3(R)*unitcircle3;
surface scle=surface(cle);
draw(scle, black);
draw(rotate(90,X)*scle, black);
draw(rotate(-90,Y)*scle, black);

draw(surface(sphere(center,R)), p);

triple vcam=1e5*currentprojection.camera-center;
for (int phi=0; phi<360; phi+=angle) {
  bool[] back,front;
  save();

  for (int i=0; i<nbpts; ++i) {
    P[i]=T*P[i];
    bool test=dot(P[i]-center,vcam) > 0;
    front.push(test);
  }

  curve=T*curve;
  draw(segment(P,front,operator ..), paleyellow);
  draw(segment(P,!front,operator ..),0.5*(paleyellow+p));
  draw((planeproject(xy)*curve)^^
       (planeproject(xz)*curve)^^
       (planeproject(yz)*curve), paleyellow);

  A.add();
  restore();
}

A.movie(options="-density 350 -resample 96 -quality 100 -depth 8 -strip");

Étiquettes : , , , , , , , ,


Animation with Asymptote – fig0100

Category: Animation,AsymptotePh. Ivaldi @ 17 h 20 min

Figure 0010
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import animation;
import graph;

settings.tex="pdflatex";
settings.outformat="pdf";

unitsize(x=2cm,y=1.5cm);

typedef real realfcn(real);

real lambda=4;
real T=2;
real [] k=new real[3];
real [] w=new real[3];
k[0]=2pi/lambda;
w[0]=2pi/T;
real dk=-.5;
k[1]=k[0]-dk;
k[2]=k[0]+dk;
real dw=1;
w[1]=w[0]-dw;
w[2]=w[0]+dw;

real vp=w[1]/k[1];
real vg=dw/dk;

realfcn F(real x) {
  return new real(real t) {
    return cos(k[1]*x-w[1]*t)+cos(k[2]*x-w[2]*t);
  };
};

realfcn G(real x) {
  return new real(real t) {
    return 2*cos(0.5*(k[2]-k[1])*x+0.5*(w[1]-w[2])*t);
  };
};

realfcn operator -(realfcn f) {return new real(real t) {return -f(t);};};

animation A;

real tmax=abs(2pi/dk);
real xmax=abs(2pi/dw);

pen envelope=0.8*blue;
pen fillpen=lightgrey;

int n=50;
real step=tmax/(n-1);
for(int i=0; i < n; ++i) {
  save();
  real t=i*step;
  real a=xmax*t/tmax-xmax/pi;
  real b=xmax*t/tmax;
  path f=graph(F(t),a,b);
  path g=graph(G(t),a,b);
  path h=graph(-G(t),a,b);
  fill(buildcycle(reverse(f),g),fillpen);
  draw(f);
  draw(g,envelope);
  draw(h,envelope);
  A.add();
  restore();
}

for(int i=0; i < n; ++i) {
  save();
  real t=i*step;
  real a=-xmax/pi;
  real b=xmax;
  path f=graph(F(t),a,b);
  path g=graph(G(t),a,b);
  path h=graph(-G(t),a,b);
  path B=box((-xmax/pi,-2),(xmax,2));
  fill(buildcycle(reverse(f),g,B),fillpen);
  fill(buildcycle(f,g,reverse(B)),fillpen);
  draw(f);
  draw(g,envelope);
  draw(h,envelope);
  A.add();
  restore();
}

A.movie();

Étiquettes : , , , ,


Animation with Asymptote – fig0110

Category: Animation,AsymptotePh. Ivaldi @ 18 h 20 min

Figure 0011
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import geometry;
import animate;
// settings.tex="pdflatex";
// settings.outformat="pdf";

animation anim;
size(12cm);

point F1=(0,0), F2=(0,-3);
dot("F",F1);

ellipse el1=ellipse(F1,F2,2), el2;
point Fp1=shift(0,2*el1.a)*F1;
dot("F'",Fp1);

line tgt, saxe=line(F1,false,-F2);

for (int i=0; i < 360; i += 5) {
  save();
  ellipse el=rotate(i,F1)*el1;
  point M=intersectionpoints(el,saxe)[0];
  tgt=tangents(el,M)[0];
  draw(tgt, 0.8*red);
  draw((reflect(tgt)*el)^^el, linewidth(bp));
  anim.add();
  restore();
}
erase();
anim.movie();

Étiquettes : , , ,


Animation with Asymptote – fig0120

Category: Animation,AsymptotePh. Ivaldi @ 19 h 20 min

Figure 0012
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import geometry;
import animate;
settings.tex="pdflatex";
settings.outformat="pdf";

animation anim;
size(12cm);



point F1=(0,0), F2=(10,0);
dot("F",F2);
ellipse el1=ellipse(F1,F2,6), el2;
draw(el1, linewidth(bp));
point Fp2=shift(2*el1.a,0)*F2;
line tgt, saxe;
pen[] p=new pen[]{0.8*green,0.8*blue,0.8*yellow,cyan};
path[] locus=sequence(new path(int i){return nullpath;},p.length);
real t=1/(p.length-1);

bool initlocus=true;
for (int i=0; i < 360; i += 1) {
  save();
  point Fm=rotate(i,F2)*Fp2;
  dot("F'",Fm);
  draw(Fm--F2, linewidth(2bp));
  point M=intersectionpoints(el1, line(F2,false,Fm))[0];
  tgt=tangents(el1,M)[0];
  draw(tgt, 0.8*red);
  el2=reflect(tgt)*el1;
  draw(el2.F1--el2.F2);

  for (int j=0; j < p.length; ++j) {
    point P=point(segment(el2.F2,Fm),0.5+j*t/2);
    locus[j]=initlocus ? P : locus[j]--P;
    dot(P, p[j]);
    draw(locus[j], bp+p[j]);
  }

  dot(el2.F2);
  draw(el2, linewidth(bp));
  anim.add();
  restore();
  initlocus=false;
}
erase();
anim.movie();

Étiquettes : , , , ,


Animation with Asymptote – fig0130

Category: Animation,AsymptotePh. Ivaldi @ 20 h 20 min

Figure 0013
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
// From an idea posted by Fabrice Couvreur
import geometry;
import animate;
settings.tex="pdflatex";
settings.outformat="pdf";

point A=(0,0), B=(8,0), C=(8,10);
unitsize(5cm/B.x,5cm/C.y);
animation Anim,Anim1;
path locus;

triangle t=triangle(A,B,C);
transform proj=projection(t.BC);
draw(t,linewidth(bp));
label(t);
segment s=segment(t.AB);
line l1 =line(t.BC);

int n=50; // Points number of the locus
real a=0, step=1/(n-1);
for (int i=0; i < n; ++i) {
  save(); // Geometry part
  point M=point(s,a);
  line l2=parallel(M,l1);
  point Np=intersectionpoint(l2,t.AC);
  point P=proj*Np;
  dot("$M$",M,S,0.8*red);
  dot("$P$",P,E,0.8*red);
  dot("$N$",Np,W,0.8*red);
  fill(M--Np--P--B--cycle,0.8*red);
  perpendicularmark(t.BC,t.BA);
  Anim.add(); // Anim contain only the geometry part
  restore();
  // Graph part
  picture gph; // picture of the graph
  unitsize(gph,5cm/B.x,4cm/C.y); // units for the graph
  show(gph,currentcoordsys);
  point Sp=(a*abs(B-A),abs(M-B)*abs(M-Np));
  locus=locus..Sp;
  draw(gph,locus, bp+0.8*red);
  Anim1.add(gph); // Anim1 contain only the graph part
  a += step;
}

Anim1.export(); // make all Anim1 pictures to the same size.
Anim1.purge();

for (int i=0; i < Anim.pictures.length; ++i) {
  // draw axis on all pictures of Anim1
  draw(Anim1.pictures[i],Label("$x$",align=S,position=EndPoint),hline,Arrow);
  draw(Anim1.pictures[i],Label("$y$",align=W,position=EndPoint),vline,Arrow);
  // add each graph to the corresponding geometric picture
  add(Anim.pictures[i],Anim1.pictures[i].fit(),1.25*B);
}

Anim.movie();

Étiquettes : , ,


Animation with Asymptote – fig0140

Category: Animation,AsymptotePh. Ivaldi @ 21 h 20 min

Figure 0014
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
/*Inspiration*/
import Lsystem;
import animate;
animation A;
settings.tex="pdflatex";
settings.outformat="pdf";

size(10cm,0);

string[][] rules={{"A","[+BFA][-BFA][^BFA][&BFA]"}, {"B", "'(0.7071)"}};
Lsystem3 plant=Lsystem3("A", rules, La=45);
plant.iterate(5);
tree3 g=plant.tree3();

for (int angle=0; angle < 360; angle += 5) {
  currentprojection=orthographic(rotate(angle,Z)*(10,10,6));
  save();
  for (int i : g.keys)
    draw((path3)g[i], linewidth(bp)+(g[i].depth > 3 ? brown : 0.8*green));
  A.add();
  restore();
}

A.movie();

Étiquettes : ,


Animation with Asymptote – fig0150

Category: Animation,AsymptotePh. Ivaldi @ 22 h 20 min

Figure 0015
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
/*Inspiration*/
import Lsystem;
import animate;

settings.tex="pdflatex";
settings.outformat="pdf";

animation A;
size(10cm,0);

string[][] rules={{"X","^<XF^<XFX-F^>>XFX&F+>>XFX-F>X->"}};
Lsystem3 HilbertCurve3D=Lsystem3("X", rules, La=90, Lai=0);
HilbertCurve3D.iterate(3);

path3[] g=HilbertCurve3D.paths3();
triple M=(max(g)+min(g))/2;
currentprojection=currentprojection=orthographic((10,10,6));

for (int angle=0; angle < 360; angle += 2) {
  save();
  draw(rotate(angle,M,M+Z)*g[0], linewidth(bp)+0.9*yellow);
  A.add();
  restore();
}

A.movie(BBox(3mm, Fill(black)));

Étiquettes : , ,


Animation with Asymptote – fig0160

Category: Animation,AsymptotePh. Ivaldi @ 23 h 20 min

Figure 0016
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import graph_settings;
import animate;
size(10cm);
settings.tex="pdflatex";
settings.outformat="pdf";

pair[] interp(pair[] a1, pair[] a2, real k)
{
  if(a1.length != a2.length) abort("interp: arrays have differents length.");
  pair[] g;
  int l=a1.length;
  g=sequence(new pair(int j){
      return interp(a1[j],a2[j],k);
    },l);
  return g;
}

path morphing(pair[] a1, pair[] a2, real k, interpolate join=operator --)
{
  if(a1.length != a2.length) abort("morphing: arrays have differents length.");
  return join(...interp(a1, a2, k));
}

pair[] nodes(path g, int n)
{
  int np=round(n/length(g));
  n=np == 0 ? n : np*length(g);
  return sequence(new pair(int i){return point(g, length(g)*i/n);}, n);
}

animation A;

int nbpt=4;
pair[] A1=nodes(unitsquare,nbpt);
path g=(0,0)--(1,0)--(0,1)--(1,1)--cycle;
pair[] A2=shift(2,1)*rotate(25)*nodes(g,nbpt);
interpolate join=operator ..;
// interpolate join=operator --;


int n=40;
real step=1/n;
pen p1=0.8*red, p2=0.8*blue;

filldraw(join(morphing(A1,A2,0,join),cycle), p1);
filldraw(join(morphing(A1,A2,1,join),cycle), p2);

for (int i=0; i <= n; ++i) {
  save();
  filldraw(join(morphing(A1,A2,i*step,join),cycle),opacity(0.5)+interp(p1,p2,i*step));
  A.add();
  restore();
}

A.movie();

Étiquettes : , , ,


Animation with Asymptote – fig0170

Category: Animation,AsymptotePh. Ivaldi @ 0 h 20 min

Figure 0017
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import graph;
import animate;
size(15cm);
settings.outformat="pdf";

pair[] interp(pair[] a1, pair[] a2, real k)
{
  if(a1.length != a2.length) abort("interp: arrays have differents length.");
  pair[] g;
  int l=a1.length;
  g=sequence(new pair(int j){
      return interp(a1[j],a2[j],k);
    },l);
  return g;
}

path morphing(pair[] a1, pair[] a2, real k, interpolate join=operator --)
{
  if(a1.length != a2.length) abort("morphing: arrays have differents length.");
  return join(...interp(a1, a2, k));
}

pair[] nodes(path g, int n)
{
  int np=round(n/length(g));
  n=np == 0 ? n : np*length(g);
  return sequence(new pair(int i){return point(g, length(g)*i/n);}, n);
}

animation A;

real f(real t){ return exp(cos(t))-2*cos(4*t)+sin(t/12)^5;}
path gf=polargraph(f,0,12*pi,1000);

int nbpt=1000;
pair[] A1=nodes(scale(5.5)*unitcircle,nbpt);
pair[] A2=shift(0,0)*nodes(gf,nbpt);
interpolate join=operator --;


int n=50;
real step=1/n;
pen p1=0.8*red, p2=0.8*blue;

for (int i=0; i <= n; ++i) {
  save();
  filldraw(join(morphing(A1,A2,1,join),cycle),
           evenodd+p2);
  filldraw(join(morphing(A1,A2,i*step,join),cycle),
           evenodd+interp(p1,p2,i*step));
  A.add();
  restore();
}

A.movie(BBox(3mm, 3bp+miterjoin+black, FillDraw(lightyellow)));

Étiquettes : , , ,


Animation with Asymptote – fig0180

Category: Animation,AsymptotePh. Ivaldi @ 1 h 20 min

Figure 0018
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
// pdf version of this animation: fig0180.pdf
import labelpath;
import animate;
animation A;

texpreamble("\usepackage[dvips,pdfpagemode=FullScreen]{hyperref}");
settings.outformat="pdf";
settings.tex="pdflatex";
defaultpen(fontsize(12pt));

size(16cm,0);
usepackage("mathrsfs, amsfonts,amsmath,amssymb");
picture pic, pic1, pic2, pic3;
real u=1, Y=2*pi+0.5;
pair yM=(u,Y*u), ym=(u,-Y*u);
path cle=scale(u)*unitcircle;
path arcg=arc((0,0),1.5*u,115,155);

void addtick(picture pic=currentpicture, Label L, pair z, pair dir=E, pen p=currentpen)
{
  transform R=rotate(degrees(dir));
  real width=1.5mm;
  Label L=L.copy();
  L.position(z);
  L.align(NoAlign,E);
  L.align.dir=R*L.align.dir*1.3*width/mm;
  L.p(p);
  pic.add(new void(frame f, transform t) {
      path g=(-width,0)--(width,0);
      picture opic;
      draw(opic,shift(t*z)*R*g,p);
      add(f,opic.fit());
    });
  add(pic,L);
}

path roll(picture pic=currentpicture, real x, int nb=50)
{
  real stp=x/(nb-1);
  return operator --(...
                     sequence(new guide(int t){
                         real tt=t*stp;
                         return shift(expi(tt))*((x-tt)*(-sin(tt),cos(tt)));
                       },nb));
}

pair EW(int sign){return sign > 0 ? E : W;}

string pm(int sign){return sign > 0 ? "" : "-";}

pen p(int sign){return sign > 0 ? red : blue;}
pen pw(int sign){return p(sign)+(sign > 0 ? currentpen : white);}

// Define common picture
draw(scale(1.25)*"+", arcg, Arrow());
dot("$0$", point(cle,0));

draw((-u,0)--(u,0)^^(0,-u)--(0,u));
draw("$1$",(0,0)--point(cle,1.5),Arrows(FillDraw(white)));

pic.add(currentpicture);// Save the common picture in 'pic'.

// Starting picture 1
draw((u,0)--yM, linewidth(bp)+p(1), Arrow(TeXHead));
draw(ym--(u,0), linewidth(bp)+p(-1));
arrow("\underline{Axe des réels}",(u,-0.75*Y*u),W,1cm);

real x=2.2, y=-x, maxe=2*pi+0.2;
addtick(Label("$1$",align=E), (u,1), p(1));
addtick(Label("$\frac{\pi}{2}$",align=E), (u,pi/2), p(1));
addtick(Label("$\pi$",align=E), (u,pi), p(1));
addtick(Label("$\frac{3\pi}{2}$",align=E), (u,3pi/2), p(1));
addtick(Label("$2\pi$",align=E), (u,2pi), p(1));
addtick(Label("$-1$",align=W), (u,-1), p(-1));
addtick(Label("$-\frac{\pi}{2}$",align=W), (u,-pi/2), p(-1));
addtick(Label("$-\pi$",align=W), (u,-pi), p(-1));
addtick(Label("$-\frac{3\pi}{2}$",align=W), (u,-3pi/2), p(-1));
addtick(Label("$-2\pi$",align=W), (u,-2pi), p(-1));

draw(Label("$\mathscr{C}$",Relative(0.625)), cle,linewidth(bp));
A.add();
erase();

// Define the common picture for rolling part.
picture picanim(int sign)
{
  picture opic=pic.copy();
  pen pmoins=sign > 0 ? p(-1) : p(-1)+white;
  draw(opic, (u,0)--yM, bp+white+p(1), Arrow(TeXHead));
  draw(opic, ym--(u,0), linewidth(bp)+pmoins);
  arrow(opic,"\underline{Axe des réels}", (u,-0.75*Y*u), W, 1cm);
  addtick(opic, Label("$1$",align=E), (u,1), white+p(1));
  addtick(opic, Label("$\frac{\pi}{2}$",align=E), (u,pi/2), white+p(1));
  addtick(opic, Label("$\pi$",align=E), (u,pi), white+p(1));
  addtick(opic, Label("$\frac{3\pi}{2}$",align=E), (u,3pi/2), white+p(1));
  addtick(opic, Label("$2\pi$",align=E), (u,2*pi), white+p(1));
  addtick(opic, Label("$-1$",align=W), (u,-1), pmoins);
  addtick(opic, Label("$-\frac{\pi}{2}$",align=W), (u,-pi/2), pmoins);
  addtick(opic, Label("$-\pi$",align=W), (u,-pi), pmoins);
  addtick(opic, Label("$-\frac{3\pi}{2}$",align=W), (u,-3pi/2), pmoins);
  addtick(opic, Label("$-2\pi$",align=W), (u,-2*pi), pmoins);
  return opic;
}

erase();
pic2=picanim(1);

int nb=50; // Number of picture for rolling.
real step=maxe/nb;

for (int sign=1; sign > -2; sign -= 2) {// Rolling axis part (1 for positive values, -1 for ...);
  guide r1,rpis2, rpi, rpi32, rpi2;
  pair z;
  for (int i=0; i <= nb ; ++i) {
    real t=sign*i*step; // Where is the tangency.

    if(sign > 0) draw(Label("$\mathscr{C}$",Relative(0.625)), cle,linewidth(bp));
    path tg=i == nb ? cle : arc((0,0),u,0,degrees(t)); // The rolled part.
    path g=u*expi(t)--shift(u*expi(t))*((Y-abs(t))*u*expi(sign*pi/2+t)); // The straight part.
    draw(g,linewidth(bp)+p(sign), sign > 0 ? Arrow(TeXHead) : None);

    if(t > 0) {
      if(abs(t) <= 1) {
        z=arcpoint(g, (1-abs(t))*u);
        addtick(Label(pm(sign)+"$1$",align=EW(sign)), z, expi(sign), p(sign));
        r1=r1..z;
      } else addtick(Label(pm(sign)+"$1$",align=EW(sign), UnFill),
                     u*(cos(sign),sin(sign)), dir(degrees(sign*1.0)), p(sign));}

    draw(r1, dashed+p(sign));

    if(abs(t) <= pi/2) {
      z=arcpoint(g,(pi/2-abs(t))*u);
      addtick(Label("$"+pm(sign)+"\frac{\pi}{2}$",align=EW(sign)), z, expi(t), p(sign));
      rpis2=rpis2..z;
    } else addtick(Label("$"+pm(sign)+"\frac{\pi}{2}$",align=EW(sign), UnFill),
                   (0,sign*u), sign*N, p(sign));

    draw(rpis2, dashed+p(sign));

    if(abs(t) <= pi) {
      z=arcpoint(g,(pi-abs(t))*u);
      addtick(Label("$"+pm(sign)+"\pi$",align=EW(sign)), z, expi(t), p(sign));
      rpi=rpi..z;
    } else addtick(Label("$"+pm(sign)+"\pi$",align=EW(sign), UnFill),
                   (-u,0), W, p(sign));

    draw(rpi,dashed);

    if(abs(t) <= 3*pi/2) {
      z=arcpoint(g,(3pi/2-abs(t))*u);
      addtick(Label("$"+pm(sign)+"\frac{3\pi}{2}$",align=EW(sign)), z, expi(t), p(sign));
      rpi32=rpi32..z;
    } else addtick(Label("$"+pm(sign)+"\frac{3\pi}{2}$",align=EW(sign), UnFill),
                   (0,-sign*u), sign*S, p(sign));

    draw(rpi32, dashed+p(sign));

    if(abs(t)-2*pi < -1e-5) {
      z=arcpoint(g,(2*pi-abs(t))*u);
      addtick(Label("$"+pm(sign)+"2\pi$",align=EW(sign)), z, expi(t), p(sign));
      rpi2=rpi2..z;
    } else addtick(Label("$"+pm(sign)+"2\pi$",align=(sign > 0 ? 2 : 1)*EW(sign), UnFill),
                   (u,0), E, p(sign));

    draw(rpi2, dashed+p(sign));

    if(i == nb && sign == 1) {
      draw(tg,linewidth(2*bp)+p(sign));
      pic3.add(currentpicture);
      add(pic2);
      pic2=picanim(-1);
      pic2.add(pic3);
    } else add(pic2); // Add the common picture 'pic2'.

    draw(tg,linewidth(bp)+p(sign));
    A.add();
    if(sign > 0 || i != nb) erase();
  }
}

for (int i=0; i < 10; ++i) A.add();
clip(scale(1.6)*cle);
for (int i=0; i < 10; ++i) A.add();

eval(quote{
    addtick(Label("$-\pi$",align=EW(-1), UnFill), (-u,0), W, p(-1));
    addtick(Label("$-2\pi$",align=EW(-1), UnFill), (u,0), E, p(-1));
    defaultfilename='temp_';
    shipout(currentpicture.fit(scale(2cm)));},true);

pair center=(min(currentpicture)+max(currentpicture))/2;
int n=20;
for (int i=0; i <= n; ++i) {
  erase();
  label(scale(1+1.25*i/n)*graphic("temp_.pdf"),i/n*center);
  A.add();
}

for (int i=0; i < 20; ++i) A.add();
for (int i=0; i < 10; ++i) A.add(A.pictures[0]); // Add the first picture in the animation.

A.movie();

Étiquettes : , ,


Animation with Asymptote – fig0190

Category: Animation,AsymptotePh. Ivaldi @ 2 h 20 min

Figure 0019
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
size(12cm,0);
import hull_pi;
import animation;
animation A;
settings.outformat="pdf";

pair[] cloud;
int nbpt=200;

// Generate random points.
for (int i=0; i < nbpt; ++i)
  cloud.push((10*unitrand(),10*unitrand()));

for (int i=1; i < 8; ++i) { // Control the depth
  for (int j=0; j < 30; ++j) { // Point of view = cloud[i]
    real depthMax=i/2;
    // Nodes of the hull
    pair[] hull=hull(cloud,depthMin=0,depthMax=depthMax,angleMin=10,angleMax=360,pivot=j);

    save();// Add new picture to the animation
    filldraw(polygon(hull),lightgrey);
    dot(cloud[j],3mm+green);
    dot(cloud,red);
    label("depthMax="+(string)depthMax);
    A.add();
    restore();
  }
}

A.movie();

Étiquettes : ,


Animation with Asymptote – fig0200

Category: Animation,AsymptotePh. Ivaldi @ 3 h 20 min

Figure 0020
(Compiled with Asymptote version 1.86svn-r4626)
This animation is available in the Syracuse web site.
    
/* One may want to play with an interactive Java applet */
settings.render=0;
import three;
import animation;
animation A;

size(15cm);
currentprojection=orthographic(1,1,1.5);
currentlight=(1,0,1);

triple PXY=-X-Y;
triple P00=PXY+0.5*Z, P03=-X+Y, P33=X+Y, P30=X-Y;

triple[][] P0={
  {PXY,PXY+(0,0.5,0),P03+(0,-0.5,0),P03},
  {PXY+(0.5,0,0),(-0.5,-0.5,0),(-0.5,0.5,0),P03+(0.5,0,0)},
  {P30+(-0.5,0,0),(0.5,-0.5,0),(0.5,0.5,0),P33+(-0.5,0,0)},
  {P30,P30+(0,0.5,0),P33+(0,-0.5,0),P33}
};

triple[][][] P1={
  {
    {PXY,PXY+(0,0.5,0),P03+(0,-0.5,0),P03},
    {PXY+(0.5,0,0),(-0.5,-0.5,-2),(-0.5,0.5,-2),P03+(0.5,0,0)},
    {P30+(-0.5,0,0),(0.5,-0.5,-2),(0.5,0.5,-2),P33+(-0.5,0,0)},
    {P30,P30+(0,0.5,0),P33+(0,-0.5,0),P33}
  },
  {
    {P00,P00+(-0.5,0.5,-1),P03+(0,-0.5,1),P03},
    {P00+(0.5,-0.5,-1),(-0.5,-0.5,-2),(-0.5,0.5,-2),P03+(0.5,0,1)},
    {P30+(-0.5,0,1),(0.5,-0.5,-2),(0.5,0.5,-2),P33+(-0.5,0,1)},
    {P30,P30+(0,0.5,1),P33+(0,-0.5,1),P33}
  },
  {
    {P00,P00+(-0.5,0.5,-1),P03+(0,-0.5,1),P03},
    {P00+(0.5,-0.5,-1),(-0.5,-0.5,-2),(-0.5,0.5,2),P03+(0.5,0,1)},
    {P30+(-0.5,0,1),(0.5,-0.5,-2),(0.5,0.5,-2),P33+(-0.5,0,1)},
    {P30,P30+(0,0.5,1),P33+(0,-0.5,1),P33}
  },
  {
    {P00,P00+(-0.5,0.5,-1),P03+(0,-0.5,1),P03},
    {P00+(0.5,-0.5,-1),(-0.5,-0.5,-2),(-0.5,-0.5,2),P03+(0.5,0,1)},
    {P30+(-0.5,0,1),(0.5,-0.5,-2),(0.5,0.5,-2),P33+(-0.5,0,1)},
    {P30,P30+(0,0.5,1),P33+(0,-0.5,1),P33}
  }
};

triple[][] interp(triple[][] a, triple[][] b, real x)
{
  triple[][] c;
  for (int i=0; i < a.length; ++i) {
    triple [] t;
    for (int j=0; j < a[i].length; ++j) {
      t.push(interp(a[i][j],b[i][j],x));
    }
    c.push(t);
  }
  return c;
}

int n=20;
real step=1/n;

for (int i=0; i < P1.length; ++i) {
  for (int j=0; j <= n; ++j) {
    save();
    triple[][] P=interp(P0,P1[i],j*step);
    surface s=surface(P);
    draw(s,15,15,yellow,meshpen=grey);
    draw(sequence(new path3(int i){
          return s.s[i].external();},s.s.length), bp+red);

    dot("P[0][0]",P[0][0], align=N, black);
    dot("P[0][3]",P[0][3], black);
    dot("P[3][3]",P[3][3], align=S, black);
    dot("P[3][0]",P[3][0], align=W, black);

    draw(Label("P[0][1]",align=SW,EndPoint),P[0][0]--P[0][1], Arrow3);
    draw(Label("P[1][0]",align=SE,EndPoint),P[0][0]--P[1][0], Arrow3);

    draw(Label("P[0][2]",align=E,EndPoint),P[0][3]--P[0][2], Arrow3);
    draw(Label("P[1][3]",align=W,EndPoint),P[0][3]--P[1][3], Arrow3);

    draw(Label("P[2][3]",align=NE,EndPoint),P[3][3]--P[2][3], Arrow3);
    draw(Label("P[3][2]",align=NW,EndPoint),P[3][3]--P[3][2], Arrow3);

    draw(Label("P[3][1]",align=NE,EndPoint),P[3][0]--P[3][1], Arrow3);
    draw(Label("P[2][0]", align=W,EndPoint),P[3][0]--P[2][0], Arrow3);


    dot("P[1][1]",P[1][1], align=N);
    dot("P[1][2]",P[1][2], align=E);
    dot("P[2][2]",P[2][2], align=N);
    dot("P[2][1]",P[2][1], align=W);

    A.add();
    restore();
  }
  P0=copy(P1[i]);
}

for (int i=A.pictures.length-1; i >= 0 ; --i)
  A.add(A.pictures[i]);

A.movie(BBox(Fill(lightgrey)));

Étiquettes : , , , ,