# Animations

## Cardioïde

On prend un cercle de diamètre 2a passant par l'origine. On trace une tangente quelconque à ce cercle en un point P. On projette ensuite O sur cette tangente, on obtient alors le point M. Si P parcourt le cercle alors M décrit une cardioïde.

cardioide.mp
%@AUTEUR: Maxime Chupin
%@DATE: 22 mars 2007

verbatimtex
%&latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
etex

u:=3cm;
a:= 2u;

vardef proj(expr P,M,N) =
save H; pair H;
H = whatever [M,N];
H - P = whatever * (M - N) rotated 90;
H
enddef;

path carre,cardioide;
carre = (0,0)--(1,0)--(1,1)--(0,1)--cycle;

for i:=0 upto 80:
beginfig(i+1);
path cercle,tangente,vec;
pair P,M,O,P';
pickup pencircle scaled 0.8;
drawarrow (-a,0)--(2a,0);
drawarrow (0,-a)--(0,a);
O:=(0,0);
pickup pencircle scaled 0.5;
cercle := fullcircle scaled a shifted (a/2,0);
draw cercle dashed evenly;

P = point (4-i/10) of cercle;

if i=0:
M = P;
cardioide = M;
fi;

if (i<>0) and (i<>40) and (i<>80):
P' = (xpart P +0.5*a, (xpart P +0.5*a)*((-xpart P)/(ypart P) +
a/(2*(ypart P)))+a*(xpart P)/(2*(ypart P)));
tangente = 5[P,P']--5[P',P];
M = proj(O,P,P');
vec = 20[O,M]--20[M,O];
cardioide := cardioide..M;
pickup pencircle scaled 1;
drawarrow cardioide withcolor red;
pickup pencircle scaled 0.5;
draw carre scaled 12 rotated (angle(M-P)+180)
shifted M dashed withdots scaled 0.3;
draw tangente withcolor blue dashed evenly;
draw vec withcolor blue dashed evenly;
dotlabel.urt(btex $M$ etex,M);
dotlabel.urt(btex $P$ etex,P);
fi;

if i=40 :
pickup pencircle scaled 1;
M:=P;
cardioide := cardioide..M;
draw cardioide withcolor red;
dotlabel.urt(btex $P$ etex,P);
fi;

if i=80 :
pickup pencircle scaled 1;
M:=P;
cardioide := cardioide..M;
draw cardioide withcolor red;
fi;
label.top(btex $a$ etex, (a/2,0));
label.llft(btex $x$ etex, (0.99*2a,0));
label.urt(btex $y$ etex, (0,0.9*a));
dotlabel.urt(btex $O$ etex,O);
label(btex $\boxed{r=a(1+\cos\theta)}$ etex,(3/2*a,a/2));
clip currentpicture to (-a,-a)--(2*a,-a)--(2*a,a)--(-a,a)--cycle;

endfig;
endfor;
end