Recreating a guilloche with TikZ

Guilloché (Guilloche) is a decorative engraving technique in which a very precise intricate repetitive pattern or design is mechanically engraved into an underlying material with fine detail. Specifically, it involves a technique of engine turning, called guilloché in French after the French engineer “Guillot”, who invented a machine “that could scratch fine patterns and designs on metallic surfaces

The problem is to draw a curve with a fixed point inside a circle

A method : I used tkz-fct because it's my package and I know it but it's easy to create the same thing with only tikz. (here you need gnuplot)

enter image description here

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


\begin{document} 

\def\spirographlike#1{%
\def\repeatno{#1}
 \foreach \i in {1,...,\repeatno}
   {%
    \begin{scope}[rotate=360/\repeatno*\i]
      \mycloedcurve
    \end{scope}}%
    } 

\def\mycloedcurve{\tkzFctPolar[color=MidnightBlue,thick,domain=0:2*pi,samples=400]{ 1+cos(3*t)+(sin(3*t))**2}}  

\noindent\begin{tikzpicture}
 \mycloedcurve 
\end{tikzpicture}    
\begin{tikzpicture}[scale=2]
 \tkzInit [xmin=-5,xmax=5,ymin=-5,ymax=5] 
  \spirographlike{40}    
\end{tikzpicture} 

\end{document}

update

enter image description here This is better but you need some time to compile

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


\begin{document} 

\def\spirographlike#1{%
\def\repeatno{#1}
 \foreach \i in {1,...,\repeatno}
   {%
    \begin{scope}[rotate around={360/\repeatno*\i:(.5,0)}]
      \mycloedcurve
    \end{scope}}%
    } 

\def\mycloedcurve{\tkzFctPolar[color=MidnightBlue,thick,domain=0:2*pi,samples=400]{ 1+cos(3*t)+(sin(3*t))**2}}    

\begin{tikzpicture}
 \mycloedcurve 
\end{tikzpicture}    
\begin{tikzpicture}[scale=2]
 \tkzInit [xmin=-5,xmax=5,ymin=-5,ymax=5] 
  \spirographlike{20}    
\end{tikzpicture} 

\end{document} 

So here's an approach to draw the 'straight' parts. (Might be a bit crude to more seasoned people...)

The compile time is certain to put the most patient of us to test, but that's to be expected with TikZ doing such things... :)

I only plotted one such sample from the ones I found at Mathworld. So there are some samples ready to be downloaded. They are (as you can see below) a sum of lots of sines and the essential trick to get them to mesh together beautifully is to control the 'frequency' and the 'initial phase'.

So here's the code:

\documentclass[12pt,a4paper]{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[very thin]

\foreach \n in {0,...,19}
    {
        \foreach \x [remember=\x as \lastx (initially 0)] in {0.01,0.02,...,6.28}
            {
                \draw [red] (\lastx*2,{(4+sin(5*(180*\lastx/pi)))+((7+sin(7*(180*\lastx/pi)))-(4+sin(5*(180*\lastx/pi))))*(1+sin(5*(180*\lastx/pi)+\n*20))/2}) -- (\x*2,{(4+sin(5*(180*\x/pi)))+((7+sin(7*(180*\x/pi)))-(4+sin(5*(180*\x/pi))))*(1+sin(5*(180*\x/pi)+\n*20))/2});
            }
    }

\end{tikzpicture}

\end{document}

As you can see, I had to rescale a bit the coordinates, primarily because the source formulas used radians and TikZ likes degrees... Also I stretched a bit the thing along the x axis for looks.

And this is what you get after - well - a while:

enter image description here

Faster Code:

The idea is to reuse the previous coordinate instead of recomputing it with the use of \lastx. Further this means that there will only be {0,...,19} draw commands instead of 20\times6.29/0.01=12580.
This feature is used by doing an inline for-loop.

So instead you would do:

\begin{tikzpicture}[very thin]

  \foreach \n in {0,...,19} {
      \draw [red] (0,{(4+sin(5*(0)))+((7+sin(7*(0)))-(4+sin(5*(0))))*(1+sin(5*(0)+\n*20))/2}) 
      \foreach \x in {0.01,0.02,...,6.28} { 
          -- (\x*2,{(4+sin(5*(180*\x/pi)))+((7+sin(7*(180*\x/pi)))-(4+sin(5*(180*\x/pi))))*(1+sin(5*(180*\x/pi)+\n*20))/2}) 
      }; % <- Here the \draw ends
  }
\end{tikzpicture}

For further speed the computation of the angles could be made more explicit, and shorter expression could be made:

\begin{tikzpicture}[very thin]
  \foreach \n in {0,...,19} {
      \draw [red] (0,{4+(7-4)*(1+sin(\n*20))/2}) 
      \foreach \x in {0.5,1,...,360} { 
          -- ({6.28318*\x/180},{4+sin(5*\x)+(7+sin(7*\x)-(4+sin(5*\x)))*(1+sin(5*\x+\n*20))/2})
      };
  }
\end{tikzpicture}

As a last optimization all variables that can be reduced should be, this will not give as much, as it is simple multiplication and division:

\begin{tikzpicture}[very thin]
  \foreach \n [evaluate={\n*20} as \ntwenty] in {0,...,19} {
      \draw [red] (0,{5.5+1.5*sin(\ntwenty))}) 
      \foreach \x [evaluate={sin(5*\x)} as \sfx] in {0.5,1,...,360} { 
          -- ({0.034906585039886591*\x},{4+\sfx+(3+sin(7*\x)-\sfx)*(1+sin(5*\x+\ntwenty))/2})
      };
  }
\end{tikzpicture}

And actually it does compiler twice as fast, and faster for the last, when changing from evaluate to \pgfextra\pgfmathparse{sin(5*\x)}\edef\sfx{\pgfmathresult}\endpgfextra there is no gain, so is not showed:

  1. 1m59.699s
  2. 0m59.100s
  3. 0m43.627s
  4. 0m38.714s

An alternative to creating guillochés with TikZ is to use a third-party tool to produce them as graphics files, and then import them into your document using the usual \includegraphics{…}.

I'm aware of the following guilloché tools:

GuardSoft Cerberus

A sophisticated, proprietary guilloché tool for Microsoft Windows that can export to PostScript. Prices are not listed on the website, though I gather that it's very expensive (thousands of dollars).

Screenshot of GuardSoft Cerberus

Excentro

Another proprietary Guilloché generator, available for $500 for Mac OS. There is also a "Lite" version available for $25. Bitmap and PDF outputs are supported.

Screenshot of Excentro

Guilloché Pattern Generator

A free-as-in-beer Adobe Flash application that you can use from a web browser. You simply select the desired foreground and background colours and adjust a series of sliders to control the size and shape of the pattern. The patterns can be saved as JPEG images by pressing S. If your system has a printer driver that outputs PDF files, then you can supposedly print vectorized PDFs by right-clicking and selecting "Print Guilloche". (I haven't tested this myself.)

Screenshot of subblue's Guilloché Pattern Generator

Vectorizer

A reimplementation of subblue's Guilloché Pattern Generator in HTML and JavaScript. It can output the image as a PNG or SVG graphic. (You can then use your favourite graphics converter, such as Inkscape or rsvg, to convert the SVG to PDF or EPS for use with LaTeX.)

Screenshot of Vectorizer

Tags:

Tikz Pgf