Retour

Source : cycloide.mp

Animation flash


cycloide.mp
input geometriesyr16;
pair O,P,I[],N[],centre[];
path roule,cc[];
u:=7.5mm;
rayon=2;
O=u*(2,1);
P-O=u*(2*pi*rayon,0);
centre[0]=u*(2,1+rayon);
roule=cercles(centre[0],rayon*u);
I0=O;
N0=O;
for j=1 upto 100:
  centre[j]=(j/100)[centre[0],centre[0] shifted(P-O)];
  N[j]=projection(centre[j],O,P);
  if abs(O-N[j])<=(pi*rayon):
    I[j]=rotation(N[j],centre[j],-c*(abs(O-N[j]))/rayon);
  else:
    I[j]=rotation(N[j],centre[j],c*(abs(P-N[j]))/rayon);
  fi;
endfor;
cc1=O
for j=1 upto 100:
  ..I[j]
endfor;
vues=20;
for vue=0 upto vues:
  figure(-0.5u,0,16.5u,6u);
  trace feuillet withcolor blanc;
  trace droite(O,P);
  trace roule withcolor gris;
  remplis cercles(I[5*vue],1mm) withcolor rouge;
  %marque_p:="plein";
  %pointe(centre[0],centre[50]);
  %trace droite(centre[0],centre[50]);
  trace cercles(centre[5*vue],N[5*vue]) dashed evenly;
  trace (cc1 cutafter I[5*vue]) withcolor orange;
  fin;
endfor;
end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vardef cycloide(expr n)=
  pair A[],I[],O,centre[],J[];
  path cc[],poly;
  O=u*(2.5,3);
  A1=u*(1,1);
  for j=2 upto n:
    A[j]=rotation(A[j-1],O,-360/n);
  endfor;
  poly=A1
  for j=2 upto n:
    --A[j]
  endfor
  --cycle;
  for k=0 upto n-2:
    centre[k]=A[n] shifted(k*(A[n]-A[1]));
  endfor;
  I0=A1;
  for k=0 upto (n-2):
    for j=1 upto (360/n):
      I[k*(360/n)+j]=rotation(I[k*(360/n)],centre[k],-j);
    endfor;
  endfor;
  J0=O;
  for k=0 upto (n-2):
    for j=1 upto (360/n):
      J[k*(360/n)+j]=rotation(J[k*(360/n)],centre[k],-j);
    endfor;
  endfor;
  cc1=I[0]
  for j=1 upto (360-360/n):
    ..I[j]
  endfor
  ;
enddef;
n=12;
w=(60/n);
roulades(n);
vues=(n-1)*6;
for vue=0 upto vues:
  figure(-1u,0,19u,7u);
  trace droite(A1,A[n]);
  trace poly withcolor gris;
  marque_p:="plein";
  for p=1 upto n:
    pointe(A[p]);
  endfor;
  remplis cercles(I[w*vue],1mm) withcolor rouge;
  if vue<>0:
    for p=0 upto n-2:
      if (vue>=(6*p+1)) and (vue<=6*(p+1)):
	trace centre[p]
	for k=1 upto n-1:
	  --rotation(centre[p],J[w*vue],-k*(360/n))
	endfor
	--cycle withcolor bleu;
	remplis cercles(centre[p],1mm) withcolor jaune;
      fi;
    endfor;
  fi;
  trace (cc1 cutafter I[w*vue]) withcolor orange;
  currentpicture:=rotation(currentpicture,A1,-angle(A[n]-A[1]));
  trace feuillet;
  fin;
endfor;
end