Some Animation

FP
Using several packages available in the LaTeX world I managed to make some animation of algorithms. In case you want to do something like this yourself, I suggest that you install the following on your system:

  • TeX, which you probably already have; if you do not have it yet, I am wondering whether for you this is the best point to start from.
  • the following three packages:
  • the lhs2TeX program
  • the Glasgow Haskell Compiler or equivalent

In the attached file CodeTree.lhs you can see a piece of Haskell code. When you process the file with lhs2TeX the file is loaded into the ghci, which ceeates an environment in which the \perfom{...} commands in your file can be evaluated. The text resulting from these calls is inserted in the CodeTree.tex file that is generated by the call to lhs2TeX. In our example the call generates a series of numbered drawings, that can be stepped through because of the included beamer code.

Thus:

  • lhs2TeX Codetree.lhs > CodeTree.tex
  • pdfLaTeX Codetree.tex
  • acroread CodeTree.pdf

If you want to animate your own algorithm you will have to:

  1. make sure that you can reproduce the attached pdf file
  2. extend your data types with extra constructors to model the pending function calls on these data
  3. make your extended data types an instance of the class Rewite, in order to simulate the stepwise execution of your alogorithm
  4. make your data types an instance of the class Tikz, in order to map then onto a picture in the Tikz language.

If you are interested in aking animations in haskell you may also take a look at the Vital project.

-- DoaitseSwierstra - 03 Mar 2006


Topic attachments
I Attachment Action Size Date Who Comment
elsehs AnimateThroughTikz.hs manage 1.1 K 08 Jun 2006 - 14:37 DoaitseSwierstra  
elselhs CodeTree.lhs manage 3.6 K 06 Mar 2006 - 16:41 DoaitseSwierstra  
pdfpdf CodeTree.pdf manage 290.8 K 03 Mar 2006 - 16:59 DoaitseSwierstra