7

I was wondering if it is possible to make an animation in beamer. I normally work on graph theory. By a graph I mean a set of vertices and some edges joining them.

I wish to make an animation showing an isomorphism from one graph to the other. I could draw graphs using tikz package. But I don't know how to make the motion. So what I really want is to make an animation showing one point smoothly move to another point.

For example, I want something as below happen: enter image description here

Easy
  • 201
  • Related: http://tex.stackexchange.com/q/25394/1952, http://tex.stackexchange.com/q/6330/1952 – Ignasi May 24 '14 at 06:35
  • You can also find some complete examples in Texample.net: http://texample.net/tikz/examples/tag/animations/. This one is not exactly an animation but similar http://texample.net/tikz/examples/prims-algorithm/ – Ignasi May 24 '14 at 06:48
  • @Ignasi, thank your reference, but I don't want things moving with a pause, I want to have them moving smoothly. – Easy May 24 '14 at 06:49
  • http://tex.stackexchange.com/a/75797/1952, shows previous examples but smoothly animated – Ignasi May 24 '14 at 07:01
  • @Ignasi, see my new edit. – Easy May 24 '14 at 07:18
  • Could you please edit your post and add a fully compilable example of the graph? It would be a fine starting point for the solvers even if the graph is static. – Malipivo May 24 '14 at 07:25
  • @Malipivo, unfortunately, I don't know how to make these graphs in latex, I used other software (for example, geogebra) to create it. – Easy May 24 '14 at 07:28
  • @Easy I see, I usually use TikZ+animate packages for similar tasks. – Malipivo May 24 '14 at 07:31
  • @Malipivo, can you provide some example and let me see the effect? Note that I don't want things appear one after one, I want object moving. – Easy May 24 '14 at 07:42
  • @Easy I'd love to, but I can't right now. Well, this might be of interest for you as a starting point, http://ctan.mackichan.com/macros/latex2e/contrib/animate/animate.pdf – Malipivo May 24 '14 at 07:48
  • I've found this in geogebra forums: http://www.geogebra.org/forum/viewtopic.php?f=20&t=25986 – Ignasi May 24 '14 at 08:17

1 Answers1

11

I don't use beamer but one can start with that :

enter image description here

\documentclass[margin=5pt]{standalone}
\usepackage{tikz,animate}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{calc}

\xdef\C{8}
\xdef\H{4.5}

\begin{document}

\foreach \nxb in {0,.05,...,1,1,.95,...,0,0} {%
\begin{preview}
%\begin{animateinline}[controls]{10}
%   \multiframe{11}{nxb=0+.1}{%

    \begin{tikzpicture}

    \draw (-1,-.5) rectangle (2*\H,2*\H-.5) ;

    \coordinate (C6) at (0,0) ;
    \coordinate (C4) at (\C,0) ;
    \coordinate (C1) at (0,\C) ;
    \coordinate (C3) at (\C,\C) ;
    \coordinate (C2) at ($(C1)!.5!(C3)$) ;
    \coordinate (C5) at ($(C6)!.5!(C4)$) ;
    \coordinate (C7) at ($(C6)!.5!(C3)$) ;

    \coordinate (H5) at ($(C1)!.5!(C4)$) ;
    \begin{scope}[shift=(H5)]
    \coordinate (H6) at (0:\H) ;
    \coordinate (H7) at (60:\H) ;
    \coordinate (H4) at (120:\H) ;
    \coordinate (H3) at (180:\H) ;
    \coordinate (H2) at (240:\H) ;
    \coordinate (H1) at (300:\H) ;
    \end{scope}

    \foreach \i in {1,...,7} {%
        \fill ($(H\i)!\nxb!(C\i)$) circle (2pt) coordinate (M\i) ; }
    \draw (M1)--(M2)--(M3)--(M4)--(M5)--(M6)--(M7)--(M4)
        (M6)--(M1)--(M5) ;

    \end{tikzpicture}
    %}
%\end{animateinline}
\end{preview}}
\end{document}
Tarass
  • 16,912
  • two things I am not sure. 1. How can you convert it to the gif file? When I compiled your codes I got a pdf file and it shows me the consecutive slides. 2. How do you embed this into beamer? Thanks – Easy May 25 '14 at 13:29
  • To made the animated gif you see an this page, I used a step of .01 instead of .05 and imported the pdf file in gimp as calques not as images with 300 ppp, then exported it as gif, et voilà. I don't use beamer at all, maybe I will soon, but now I can't help you with this. – Tarass May 25 '14 at 14:50
  • 1
    @Easy: It's not possible to include animated gif files in beamer. You can include animations but not gif. – Ignasi May 25 '14 at 21:04