7

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:enter image description here

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.

azetina
  • 28,884
  • 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 04 '12 at 22:37

1 Answers1

8

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.

enter image description here

 \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}
Alain Matthes
  • 95,075
  • 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 04 '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 04 '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 05 '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 05 '12 at 14:32
  • 1
    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 05 '12 at 14:54
  • @Daniel you are in restricted mode. You need to allow tex to load gnuplot so you need to work with "\write18 enabled". You need to compile with --shell-escape or sometimes --enable-write18 – Alain Matthes Mar 05 '12 at 15:05
  • You need to gnuplot and you need to compile with --shell-escape option. There are a lot of answers about these problems here on on the net. – Alain Matthes Mar 05 '12 at 15:23
  • @Altermundus I don't get this thing about write18. How do I do it on Windows with Miktex 2.9 and Winedt? Or can you redirect me to a post that explains it. I am currently searching but a help here would be appreciated. – azetina Mar 05 '12 at 16:15
  • On the site you can search with write18 or shell-escape. For example http://tex.stackexchange.com/questions/37489/how-can-i-enable-write-18-on-a-miktex-installation . I describe how to do in the documentation of tkz-fct page 12. The explanation is in french but the line of code are universal. – Alain Matthes Mar 05 '12 at 16:29
  • I followed the link you provided but then I get the following error Package pgf Warning: Plot data file guilloche.tkzpolarfct.table' not found.'gnuplot' is not recognized as an internal or external command, operable program or batch file. – azetina Mar 05 '12 at 16:51
  • There are three problems with gnuplot on Windows : 1) the name of gnuplot (sometimes you need to change the name 2) the PATH gnuplot is not found if the PATH is not correct and 3) enable write18 . I upload on my site a document from a german user of the tkz packages : http://altermundus.com/SandBox/tkz_use.pdf – Alain Matthes Mar 05 '12 at 17:10
  • What does the tutorial part For use with MiKTeX, copy the file 'pgnuplot.exe' in the /bin directory to 'gnuplot.exe' mean? – azetina Mar 05 '12 at 20:25