Image

Animación de una elipse, mostrando las distancias focales

En este video explico cómo realizar una animación de una elipse en un archivo en pdf y utilizando solamente código.

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{ifthen}
\usepackage{animate}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\pgfplotsset{compat=1.17}
\newcounter{angle}
\setcounter{angle}{0}
\begin{document}
  \begin{center}
   \begin{animateinline}[loop, poster = first, controls]{20}
  \whiledo{\theangle<361}{
     \begin{tikzpicture}
      \begin{axis}[width=15cm,height=9cm,
        xlabel=$x$, ylabel=$y$,
        xmin=-6,xmax=6,
        ymin=-5,ymax=4,
        axis x line=center,axis y line=center,]
        \addplot[domain=0:360,samples=75,thick, cyan]
         ({5*cos(x)},{3*sin(x)});  
         \coordinate (F1) at (axis cs:-4,0) ;
         \node[red] at (F1) {$\bullet$};
         
         \coordinate (F2) at (axis cs:4,0);
         \node[red] at (F2){$\bullet$}; 
         
         \node [blue,above=3mm of F1] {$F_1$};
         \node [blue,above=3mm of F2] {$F_2$};            
         
         \pgfmathcos{\theangle}
         \pgfmathparse{multiply(5,\pgfmathresult)}
         \xdef\xcoor{\pgfmathresult}
         
         \pgfmathsin{\theangle}
         \pgfmathparse{multiply(3,\pgfmathresult)}
         \xdef\ycoor{\pgfmathresult}
         
         \coordinate (P) at (axis cs:\xcoor,\ycoor);
         \node[red] at (P) {$\bullet$};
         \node [red,above=3mm of P] {$P$};
         
         \draw[blue] (F1) -- (P);
         \draw[purple] (F2) -- (P);
         
         \pgfmathparse{sqrt(add(pow(\ycoor,2),pow(add(4,\xcoor),2)))}
         \xdef\dis{\pgfmathresult}
         
         \pgfmathparse{add(-4,\xcoor)}
         \pgfmathparse{pow(\pgfmathresult,2)}
         \pgfmathparse{add(pow(\ycoor,2),\pgfmathresult)}
         \pgfmathparse{sqrt(\pgfmathresult)}
         \xdef\diss{\pgfmathresult}
         
         \node[blue] at (axis cs:-3,-4){$
          \begin{array}{rcl}
            d(P,F_1)&=&\dis\
            \textcolor{red}{d(P,F_2)}&=&\textcolor{red}{\diss}\
            d(P,F_1)+d(P,F_2)&=&10.0000
          \end{array}
          $};
        \end{axis}
    \end{tikzpicture} 
    \stepcounter{angle}
    \ifthenelse{\theangle<361}{
        \newframe
    }{
           \end{animateinline}
       }
    }
  \end{center}
\end{document}
        

© Profesor Favián Arenas. 2023. Diseñado por HTML Codex