Retour

Source : Volumecone.mp

Animation flash


Volumecone.mp
input geometriesyr16;
%%[Points]
pair cyl[],cone[],sec[],sect[];
path cc[],ellipse[];
cyl0=u*(2,7);
cyl1=u*(2,1);
cyl2=u*(3.5,1);
cyl3=u*(0.5,1);
cyl4=u*(0.5,7);
cyl5=cyl4 shifted (cyl2-cyl3);
cone1=u*(6.5,1);
cone0=cone1 shifted (cyl0-cyl1);
cone3=u*(5,1);
cone2=cone3 shifted(cyl2-cyl3);
cc100=cercle((0,0),abs(cyl2-cyl1));
ellipse100=cc100 yscaled 0.25;
%Dessin des solides
picture solides;
solides=image(
figure(0,0,11u,8u);
trace feuillet withcolor blanc;
drawoptions(withpen pencircle scaled 1.5bp);
  draw cone3--cone0--cone2;
  draw subpath(0,(length ellipse100)/2) of ellipse100 shifted cone1 dashed evenly;
  draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted cone1;
  draw droite(cone0,cone1) dashed dashpattern(on 12bp off 6bp on 3bp off 6bp);
  draw droite(cyl1,cyl0) dashed dashpattern(on 12bp off 6bp on 3bp off 6bp);
  draw ellipse100 shifted cyl0;
  draw (subpath(0,(length ellipse100)/2) of ellipse100 shifted cyl1) dashed evenly;
  draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted cyl1;
  draw cyl2--cyl5;
  draw cyl3--cyl4;
  trace cotationmil(cyl5,cyl2,5mm,30,btex hauteur $h$ etex);
  trace cotationmil(cone0,cone1,2cm,30,btex hauteur $h$ etex);
  trace cotationmil(cyl1,cyl2,-7.5mm,20,btex rayon $r$ etex);
  trace cotationmil(cone1,cone2,-7.5mm,20,btex rayon $r$ etex);
  drawoptions();
  fin;
  );
_nfig:=0;
vues=5;
figure(0,0,11u,8u);
trace feuillet withcolor blanc;
draw solides;
fin;
path volcone[],volcyl[];
%picture sectioncone[],restevolume[],sectioncyl[],nouveauvolume[];
for vue=0 upto vues:
  figure(0,0,11u,8u);
    trace feuillet withcolor blanc;
  sec[vue]=(vue/vues)[cone0,cone1];
  sect[vue]=((vue/vues)/3)[cyl1,cyl0];
  h[vue]=abs((vue/vues)*(cone2-cone1));
  cc[vue]=cercle((0,0),h[vue]);
  ellipse[vue]=cc[vue] yscaled 0.25;
  volcone[vue]=(point((length ellipse100)/2) of ellipse100 shifted cone1)--(point((length ellipse[vue])/2) of ellipse[vue] shifted sec[vue])--(subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue])--(point(0) of ellipse100 shifted cone1)--(subpath(length ellipse100,(length ellipse100)/2) of ellipse100 shifted cone1)--cycle;
  volcyl[vue]=(point((length ellipse100)/2) of ellipse100 shifted cyl1)--(point((length ellipse100)/2) of ellipse100 shifted sect[vue])--(subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vue])--(point(0) of ellipse100 shifted cyl1)--(subpath(length ellipse100,(length ellipse100)/2) of ellipse100 shifted cyl1)--cycle;
  if vue=0:
    fill volcone[vue] withcolor jaune;
    fill (ellipse[vue] shifted sec[vue]) withcolor jaune;
    draw subpath(0,(length ellipse[vue])/2) of ellipse[vue] shifted sec[vue] dashed evenly;
  draw subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue];
  fi
  if (vue>0) and (vue<vues):
    fill volcyl[vue] withcolor ciel;
    fill (ellipse100 shifted sect[vue]) withcolor ciel;
    fill (ellipse[vue] shifted sec[vue]) withcolor jaune;
    fill volcone[vue] withcolor jaune;
    draw subpath(0,(length ellipse[vue])/2) of ellipse[vue] shifted sec[vue] dashed evenly;
    draw subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue];
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[vue] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vue];
  fi
  if vue=vues :
    fill volcyl[vue] withcolor ciel;
    fill (ellipse100 shifted sect[vue]) withcolor ciel;
    draw subpath(0,(length ellipse[vue])/2) of ellipse[vue] shifted sec[vue] dashed evenly;
    draw subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue];
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[vue] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vue];
  fi
  draw solides;
  fin;
endfor
%%----------------
%%2eme remplissage
%%----------------
for vue=0 upto vues:
  figure(0,0,11u,8u);
    trace feuillet withcolor blanc;
  k:=1+(vue/vues);
  sect[vues+vue+1]=(k/3)[cyl1,cyl0];
  h[vue]:=abs((vue/vues)*(cone2-cone1));
  cc[vues+vue+1]=cercle((0,0),h[vue]);
  ellipse[vues+vue+1]=cc[vues+vue+1] yscaled 0.25;
  volcone[vues+vue+1]=(point((length ellipse100)/2) of ellipse100 shifted cone1)--(point((length ellipse[vue])/2) of ellipse[vue] shifted sec[vue])--(subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue])--(point(0) of ellipse100 shifted cone1)--(subpath(length ellipse100,(length ellipse100)/2) of ellipse100 shifted cone1)--cycle;
  volcyl[vues+vue+1]=(point((length ellipse100)/2) of ellipse100 shifted cyl1)--(point((length ellipse100)/2) of ellipse100 shifted sect[vues+vue+1])--(subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vues+vue+1])--(point(0) of ellipse100 shifted cyl1)--(subpath(length ellipse100,(length ellipse100)/2) of ellipse100 shifted cyl1)--cycle;
  if vue=0 :
    fill volcyl[vues] withcolor ciel;
    fill (ellipse100 shifted sect[vues]) withcolor ciel;
    fill volcone[vue] withcolor jaune;
    fill (ellipse[vue] shifted sec[vue]) withcolor jaune;
    draw subpath(0,(length ellipse[vue])/2) of ellipse[vue] shifted sec[vue] dashed evenly;
    draw subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue];
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[vues] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vues];
  fi
  if (vue>0) and (vue<vues) :
    fill volcyl[vues+vue+1] withcolor ciel;
    fill (ellipse100 shifted sect[vues+vue+1]) withcolor ciel;
    fill (ellipse[vue] shifted sec[vue]) withcolor jaune;
    fill volcone[vue] withcolor jaune;
    draw subpath(0,(length ellipse[vue])/2) of ellipse[vue] shifted sec[vue] dashed evenly;
    draw subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue];
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[vues+vue+1] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vues+vue+1];
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[vues] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vues];
  fi
  if vue=vues :
    fill volcyl[vues+vue+1] withcolor ciel;
    fill (ellipse100 shifted sect[vues+vue+1]) withcolor ciel;
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[vues+vue+1] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vues+vue+1];
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[vues] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vues];
  fi
  draw solides;
  fin;
endfor
%%----------------
%%3eme remplissage
%%----------------
for vue=0 upto vues:
  figure(0,0,11u,8u);
    trace feuillet withcolor blanc;
  k:=2+(vue/vues);
  sect[2*vues+1+vue+1]=(k/3)[cyl1,cyl0];
  h[vue]:=abs((vue/vues)*(cone2-cone1));
  cc[2*vues+1+vue+1]=cercle((0,0),h[vue]);
  ellipse[2*vues+1+vue+1]=cc[2*vues+1+vue+1] yscaled 0.25;
  volcone[2*vues+1+vue+1]=(point((length ellipse100)/2) of ellipse100 shifted cone1)--(point((length ellipse[vue])/2) of ellipse[vue] shifted sec[vue])--(subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue])--(point(0) of ellipse100 shifted cone1)--(subpath(length ellipse100,(length ellipse100)/2) of ellipse100 shifted cone1)--cycle;
  volcyl[2*vues+1+vue+1]=(point((length ellipse100)/2) of ellipse100 shifted cyl1)--(point((length ellipse100)/2) of ellipse100 shifted sect[2*vues+1+vue+1])--(subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[2*vues+1+vue+1])--(point(0) of ellipse100 shifted cyl1)--(subpath(length ellipse100,(length ellipse100)/2) of ellipse100 shifted cyl1)--cycle;
  if vue=0 :
    fill volcyl[2*vues+1] withcolor ciel;
    fill (ellipse100 shifted sect[2*vues+1]) withcolor ciel;
    fill volcone[vue] withcolor jaune;
    fill (ellipse[vue] shifted sec[vue]) withcolor jaune;
    draw subpath(0,(length ellipse[vue])/2) of ellipse[vue] shifted sec[vue] dashed evenly;
    draw subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue];
  fi
  if (vue>0) and (vue<vues) :
    fill volcyl[2*vues+1+vue+1] withcolor ciel;
    fill (ellipse100 shifted sect[2*vues+1+vue+1]) withcolor ciel;
    fill (ellipse[vue] shifted sec[vue]) withcolor jaune;
    fill volcone[vue] withcolor jaune;
    draw subpath(0,(length ellipse[vue])/2) of ellipse[vue] shifted sec[vue] dashed evenly;
    draw subpath((length ellipse[vue])/2,length ellipse[vue]) of ellipse[vue] shifted sec[vue];
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[2*vues+1+vue+1] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[2*vues+1+vue+1];
  fi
  if vue=vues :
    fill volcyl[2*vues+1+vue+1] withcolor ciel;
    fill (ellipse100 shifted sect[2*vues+1+vue+1]) withcolor ciel;
    draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[2*vues+1+vue+1] dashed evenly;
    draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[2*vues+1+vue+1];
  fi
  draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[vues] dashed evenly;
  draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[vues];
  draw subpath(0,(length ellipse100)/2) of ellipse100 shifted sect[2*vues+1] dashed evenly;
  draw subpath((length ellipse100)/2,length ellipse100) of ellipse100 shifted sect[2*vues+1];
  draw solides;
  fin;
  endfor
end