# Mathematica code into TikZ code

In my search to understand the creation of a guilloche and in relation to my post Recreating a guilloche with TikZ, I came about the code below,

 Guilloche[a_, b_, c_, d_, e_, f_] :=
PolarPlot[Evaluate[Flatten[{ Table[(c + Sin[a x + d]) + ((b + Sin[b x + e]) - (c + Sin[a x + d]))(f + Sin[a x + n/ Pi])/2, {n, 0, 19}] }] ], {x, 0, 2 Pi}, PlotPoints -> 200, Axes -> None, Frame -> False]

Guilloche[4, 8, 20, 4.7, 1.8, 1];


Written in Mathematica which should produce the following image:

My attempt below compiles but with no image.

 \documentclass[11pt]{scrartcl}
\usepackage[dvipsnames]{xcolor}
\usepackage{tkz-fct}

\begin{document}
\noindent\begin{tikzpicture}
\foreach \i in {1,...,19}{%
\tkzFctPolar[color=MidnightBlue,thick,domain=0:2*pi,samples=400]{(4 + sin(4*t + 4.7)) +((8 + sin(8*t + 1.8)) - (20 + sin(4*t + 4.7)))
(1 + sin(4*t + \i/ Pi))/2}}
\end{tikzpicture}

\end{document}


Any assistance on how to convert the code appropriately will be highly appreciated. In general, the Mathematica code should produce different guilloches but I don't know how I would be able to implement it into TikZ to generate different guilloches from one piece of code.

-
You get no image because your setting for xmin xmax ymin ymax and xstep, ystep are wrong. You take the values by default. You need to give a try to pgplots because my tools are rudimentary. – Alain Matthes Mar 4 '12 at 22:37

It's a problem of units. You can use mathematica or excel or maxima or a free soft to calculate some values. After it's easy to find how to setup \tkzInit. Perhaps it's more easy with pgfplots.

 \documentclass{standalone}
\usepackage[dvipsnames]{xcolor}
\usepackage{tkz-fct}

\begin{document}
\noindent\begin{tikzpicture}
\tkzInit[xmin=-50,xmax=50,ymin=-50,ymax=50,xstep=5,ystep=5]
\foreach \i in {1,...,19}{%
\tkzFctPolar[color=MidnightBlue,thick,domain=0:4*pi,samples=400]{
(20 + sin(4*t + 4.7)) +  ((8 + sin(8*t + 1.8)) - (20 + sin(4*t + 4.7)))*
(1 + sin(4*t + \i/ 3.14))/2}}
\end{tikzpicture}

\noindent\begin{tikzpicture}
\tkzInit[xmin=-50,xmax=50,ymin=-50,ymax=50,xstep=5,ystep=5]
\foreach \i in {1,...,10}{%
\tkzFctPolar[color=MidnightBlue,thick,domain=0:4*pi,samples=400]{
(10 + sin(4*t + 4.7)) +  ((4 + sin(4*t + 1.8)) - (10 + sin(4*t + 4.7)))*
(1 + sin(4*t + \i/ 3.14))/2}}
\end{tikzpicture}

\noindent\begin{tikzpicture}
\tkzInit[xmin=-50,xmax=50,ymin=-50,ymax=50,xstep=5,ystep=5]
\foreach \i in {1,...,19}{%
\tkzFctPolar[color=MidnightBlue,thick,domain=0:4*pi,samples=400]{
(15 + sin(4*t + 4.7)) +  ((8 + sin(8*t + 1.8)) - (15 + sin(4*t + 4.7)))*
(1.5 + sin(4*t + \i/ 3.14))/2}}
\end{tikzpicture}

\end{document}

-
I appreciate the correction. By the way what do you think about this method for generating the guilloche? Interesting right? I am still learning and trying to understand how this thing works. My ultimate goal is to recreate the image I had on my first post Recreating a guilloche with TikZ. Take a look at this post. – azetina Mar 4 '12 at 23:11
Yes very interesting. I think you can get the initial picture but you need to find other shapes and after you can put all the results together. You can fix \i to 1. and you get the initial shape and after you need to make some tries – Alain Matthes Mar 4 '12 at 23:19
When I replied on my first comment I hadn't tried to compile the code above since in your post you had the image. I tried it a while ago and I can't seem to get the compilation to produce the image. Why? – azetina Mar 5 '12 at 13:42
I get the picture in 3s with pdflatex mactex 2011 pgf 2.1 cvs but I tried also with pgf 2.1 from TL and the result is fine. I update my answer with other pictures. – Alain Matthes Mar 5 '12 at 14:32
I just tried it, too, and your MWE does not return an image in the PDF. The log-file shows the following error-message, which is not thrown as a LaTeX-warning though: runsystem(gnuplot guilloche.tkzpolarfct.gnuplot)...disabled (restricted). Package pgf Warning: Plot data file 'guilloche.tkzpolarfct.table' not found. on input line 12. I'm running MaxTex 2011, but don't have gnuplot installed. Maybe the OP is missing it, too? – dhst Mar 5 '12 at 14:54