2

This is a seemingly difficult question I think. I am (or at least will be) writing a dissertation of Fractal Geometry which is to be submitted electronically. For obvious reasons, I will be hoping to include an illustration of the Mandelbrot Fractal.

There are answers available for a 'simple' image of the fractal but I was hoping there would be a way to animate this image to zoom in (in theory endlessly) – a little like this

https://www.youtube.com/watch?v=zXTpASSd9xE

but not as detailed. Does anybody know how to do this?

My preamble is currently empty so I full list of necessary packages would be great. Thank you in advance.

cgnieder
  • 66,645
PercyF2519
  • 1,025
  • Maybe important in that context http://tex.stackexchange.com/questions/162334 – Dr. Manuel Kuehner Mar 11 '17 at 17:19
  • 1
    First create a multipage PDF as in http://tex.stackexchange.com/questions/295585/cube-in-tikz-not-drawn-correctly-possibly-a-bug-in-tikz. Then google `convert pdf to animation". – John Kormylo Mar 11 '17 at 18:34
  • A multi-page PDF can be converted to GIF by one-line command: convert in.pdf out.gif. – Symbol 1 Mar 12 '17 at 17:36
  • TeX itself can barely handle the calculation. There are relatively small limitations (capacity/grouping/etc). What kind of external help do you allow? – Symbol 1 Mar 12 '17 at 19:06

1 Answers1

5

If you really want to burn your rader's/reviewer's CPU, here you are:

\documentclass[tikz]{standalone}

\def\pspreparation#1#2#3{
    20 div exch 20 div % y x
    #3 div exch #3 div % x y
    #2 add exch #1 add 2 copy true % y x y x true
}
\def\psiteration{ % y x Y X in?
    {dup dup mul 2 index dup mul sub 3 index sub 3 1 roll 2 mul mul 3 index sub exch 2 copy dup mul exch dup mul add 3 le}{false}ifelse
}
\def\psdecoration{
    5 1 roll pop pop pop pop % in?
    {0 0 0}{1 1 1}ifelse % R G B
}
\def\pgfdeclaremandelbrot#1#2#3{
    \pgfdeclarefunctionalshading{Mandelbrot(#1,#2,#3)}{\pgfpoint{-25bp}{-25bp}}{\pgfpoint{25bp}{25bp}}{}{
        \pspreparation{#1}{#2}{#3}
        \psiteration\psiteration\psiteration\psiteration\psiteration\psiteration\psiteration\psiteration
        \psiteration\psiteration\psiteration\psiteration\psiteration\psiteration\psiteration\psiteration
        \psdecoration
    }
}
\def\pgfprintmandelbrot#1#2#3{
    \pgfdeclaremandelbrot{#1}{#2}{#3}
    \tikz\path[shading={Mandelbrot(#1,#2,#3)}](-10,-10)rectangle(10,10);
}

\begin{document}
    % x-shift, y-shift, scale
    \pgfprintmandelbrot{ .6}{ 0}{1}
    \pgfprintmandelbrot{ .4}{ 0}{1.2}
    \pgfprintmandelbrot{ .2}{ 0}{1.44}
    \pgfprintmandelbrot{ .0}{ 0}{1.728}
    \pgfprintmandelbrot{-.2}{ 0}{2.0736}
    \pgfprintmandelbrot{-.4}{ 0}{2.48832}
    \pgfprintmandelbrot{-.4}{.1}{2.985984}
    \pgfprintmandelbrot{-.4}{.2}{3.5831808}
    \pgfprintmandelbrot{-.4}{.3}{4.29981696}
    \pgfprintmandelbrot{-.4}{.4}{5.159780352}
\end{document}

GIF version: (Due to the ImageMagick fails to convert PDF files containing functional shading, it is going to be glitchy)

Fixed GIF version (using Preview on Mac)

Symbol 1
  • 36,855