\documentclass{article}
\usepackage{animate}
\usepackage{luamplib}

\begin{document}


\mplibcodeinherit{enable} % pour permettre la mémoire entre les
                          % biginfig(i) produites
\newcommand{\lemniscate}[1]{% #1: l'angle en degres
  \begin{mplibcode}
    if(#1=0):
    u:=4cm;%
    a:=2u;%
    h:=a/4;%
    s:=1.3;%
    path lemn;%
    path carre;%
    carre = (0,0)--(1,0)--(1,1)--(0,1)--cycle;
    fi;
    beginfig(#1);
    pickup pencircle scaled 0.6pt;
    drawarrow (0,-s*u)--(0,s*u);
    drawarrow (-s*u,0)--(s*u,0);
    path cercle,hori,verti;
    pair O,P,Q,R,M;
    O:=(0,0);
    cercle := fullcircle scaled (a);
    pickup pencircle scaled 0.4pt;
    draw cercle dashed evenly withcolor blue;
    P:=(a/2*cosd(#1),a/2*sind(#1)); % chemin qui parcourt le cercle
    Q:=(a/2*cosd(#1),0); %projection sur (Ox)
    % projection de Q sur [O,P]
    R = cosd(#1)*cosd(#1)*(a/2*cosd(#1),a/2*sind(#1));
    % M sur [PQ] tel que QM = QR
    QR := abs(R-Q);
    if(sind(#1)>0.0):
    M = Q + (0,QR);
    else:
    M = Q - (0,QR);
    fi;

    if #1=0:
    lemn:=M;
    else:
    lemn:= lemn--M;
    fi;

    if ((#1>0) and (#1<90)) or ((#1>180) and (#1<270)):
    draw carre scaled 6 rotated (angle(Q-P)+180) shifted Q;
    draw carre scaled 6 rotated (angle(R-P)) shifted R;
    fi;
    if((#1>=90) and (#1<180)) or ((#1>=270) and (#1<360)):
    draw carre scaled 6 rotated (angle(Q-P)+180) shifted Q;
    draw carre scaled 6 rotated (angle(R-P)+180) shifted R;
    fi;

    draw O--P dashed evenly withcolor blue;
    draw P--Q dashed evenly withcolor blue;
    draw R--Q--M withcolor green;

    label.lrt(btex $a$ etex, (a/2,0));
    label.llft(btex $x$ etex, (s*u,0));
    label.llft(btex $y$ etex, (0,s*u));
    label(btex \itshape Lemniscate \par de Gerono etex, (-0.7u,1.15u));
    label(btex $x^4=a^2(x^2-y^2)$ etex, (0.7u,-1.15u));


    dotlabel.llft(btex $O$ etex, O);
    dotlabel.urt(btex $M$ etex, M);
    dotlabel.urt(btex $P$ etex, P);
    dotlabel.urt(btex $Q$ etex, Q);
    dotlabel.urt(btex $R$ etex, R);

    pickup pencircle scaled 1pt;
    draw lemn withcolor red;

    clip currentpicture to (-s*u,-s*u)--(s*u,-s*u)--(s*u,s*u)--(-s*u,s*u)--cycle;
    endfig;
  \end{mplibcode}
}


\begin{center}
  \begin{animateinline}[poster=last, controls]{24}
    %
    \multiframe{360}{i=0+1}{\lemniscate{\i}}
  \end{animateinline}
\end{center}

Le PDF produit est à télécharger dans la liste plus haut.
\end{document}
