%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                   %%
%% This is file `pst-moire-doc.tex'                                  %%
%%                                                                   %%
%% IMPORTANT NOTICE:                                                 %%
%%                                                                   %%
%% Package `pst-moire'                                               %%
%%                                                                   %%
%% Manuel Luque, Jürgen Gilg, Jean-Michel Sarlat                     %%
%%                                                                   %%
%% Copyright (C) 2018                                                %%
%%                                                                   %%
%% This program can redistributed and/or modified under              %%
%% the terms of the LaTeX Project Public License                     %%
%% Distributed from CTAN archives in directory                       %%
%% macros/latex/base/lppl.txt; either version 1.3c of                %%
%% the License, or (at your option) any later version.               %%
%%                                                                   %%
%% DESCRIPTION:                                                      %%
%%   `pst-moire' is a PSTricks package to draw moire patterns        %%
%%                                                                   %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\listfiles

\documentclass[%
    11pt,
    english,
    BCOR10mm,
    DIV12,
    bibliography=totoc,
    parskip=false,
    fleqn,
    smallheadings,
    headexclude,
    footexclude,
    oneside,
    dvipsnames,
    svgnames,
    x11names
]{pst-doc}

\usepackage[autostyle]{csquotes}
\usepackage{biblatex}
%\usepackage[style=dtk]{biblatex}
\addbibresource{pst-marble-doc.bib}
\usepackage[utf8]{inputenc}
\let\pstpersFV\fileversion
\usepackage[nomessages]{fp}
\usepackage{pstricks,pst-moire,pst-plot,pst-func,pst-lens,pstricks-add}
\usepackage{amsmath,amssymb,animate}


\definecolor{moire1}{rgb}{0.98,0.89,0.56}
\definecolor{moire2}{rgb}{0.357,0.525,0.13}
\definecolor{moire3}{rgb}{0.2,0.05,0.015}
\definecolor{moire4}{rgb}{0.070.41 0.255}

\DeclareSymbolFont{grecquesdroites}{U}{eur}{m}{n}

\DeclareMathSymbol{\BETA}{\mathord}{grecquesdroites}{12}
\DeclareMathSymbol{\DELTA}{\mathord}{grecquesdroites}{14}
\DeclareMathSymbol{\EPSILON}{\mathord}{grecquesdroites}{15}
\DeclareMathSymbol{\THETA}{\mathord}{grecquesdroites}{18}
\DeclareMathSymbol{\ALPHA}{\mathord}{grecquesdroites}{11}
\DeclareMathSymbol{\GAMMA}{\mathord}{grecquesdroites}{13}
\DeclareMathSymbol{\RHO}{\mathord}{grecquesdroites}{26}
\DeclareMathSymbol{\PI}{\mathord}{grecquesdroites}{25}
\DeclareMathSymbol{\OMEGA}{\mathord}{grecquesdroites}{33}
\DeclareMathSymbol{\TAU}{\mathord}{grecquesdroites}{28}
\DeclareMathSymbol{\MU}{\mathord}{grecquesdroites}{22}
\DeclareMathSymbol{\PHI}{\mathord}{grecquesdroites}{39}

\renewcommand\bgImage{%
\begin{pspicture}(-3,-3)(3,4.5)
\psmoire[type=Gauss,rotate=-10,scale=0.6]
\psmoire[type=Gauss,linecolor=red,scale=0.6,rotate=-20]
\end{pspicture}}

\let\belowcaptionskip\abovecaptionskip
\parindent0pt

\pstheader{pst-sin.pro}
\addtomoirelisttype{sin}
\pstheader{pst-cosine.pro}
\addtomoirelisttype{cosine}




\begin{document}

\title{pst-moire v. 2.1}
\subtitle{A PSTricks package to draw moiré patterns}
\author{%
    Jürgen \textsc{Gilg}\\
    Manuel \textsc{Luque}\\
    Jean-Michel \textsc{Sarlat}
}

\date{\today}
\maketitle
\tableofcontents
\psset{unit=1cm}

\clearpage

\begin{abstract}\parskip4pt\parindent0pt

The \texttt{pst-moire} package makes it possible to very simply create a variety of patterns obtained either by dragging one pattern on another, or by rotating one on the other. Moiré effects sometimes look very interesting. This document provides the necessary commands and divers examples.

For the interested user, we present a section \textbf{Theory} (see pages~\pageref{sec:theory}-\pageref{sec:theoryEnd}) for the mathematical background of moiré patterns.

\vfill
{\small This program can redistributed and/or modified under the terms of the LaTeX Project Public License Distributed from CTAN archives in directory \texttt{macros/latex/base/lppl.txt}; either version 1.3c of the License, or (at your option) any later version.}

\end{abstract}


\newpage


\section{The provided patterns}

\begin{center}
\psset{scale=0.4}
\begin{pspicture}(-3,-3)(3,4)
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=Fresnel}}}}
\rput(0,3){\texttt{Bands of Fresnel}}
\psmoire[linecolor=red,type=Fresnel]
\end{pspicture}
\hfill
\begin{pspicture}(-3,-3)(3,4)
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=linear}}}}
\rput(0,3){\texttt{Equidistant lines}}
\psmoire[type=linear,n=28,T=2,Rmax=2.7,linecolor=blue,scale=1]
\end{pspicture}

\begin{pspicture}(-3,-3)(3,4)
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=radial}}}}
\rput(0,3){\texttt{Radii with 3\textsuperscript{o}}}
\psmoire[linecolor=magenta,type=radial]
\end{pspicture}
\hfill
\begin{pspicture}(-3,-3)(3,4)
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=circle}}}}
\rput(0,3){\texttt{Concentric circles}}
\psset{unit=0.4}
\psmoire[linecolor=cyan,type=circle,scale=0.5]
\end{pspicture}

\begin{pspicture}(-3,-3)(3,4)
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=square}}}}
\rput(0,3){\texttt{Squares}}
\psmoire[linecolor=yellow,type=square]
\end{pspicture}
\hfill
\begin{pspicture}(-3,-3)(3,4)
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=Newton}}}}
\rput(0,3){\texttt{Squares of Newton}}
\psmoire[type=Newton]
\end{pspicture}
\hfill
\begin{pspicture}(-3,-3)(3,4)
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=Bouasse}}}}
\rput(0,3){\texttt{The pattern of H. Bouasse}}
\psmoire[type=Bouasse]
\end{pspicture}
\hfill
\begin{pspicture}(-3,-3)(3,4)
\psmoire[linecolor=red,type=Gauss,scale=0.5,E=0.4]%
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=Gauss}}}}
\rput(0,3){\texttt{The pattern of Gauss}}
\end{pspicture}
\hfill
\begin{pspicture}(-3,-3)(3,4)
\psmoire[linecolor=red,type=dot,scale=0.5]%
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=dot}}}}
\rput(0,3){\texttt{Point pattern}}
\end{pspicture}
\hfill
\begin{pspicture}(-3,-3)(3,4)
\psmoire[linecolor={[cmyk]{0 0.81 1 0.6}},type=chess,dotstyle=square*,scale=0.5]%
\rput(0,-3){\colorbox{black}{\textcolor{white}{\texttt{type=chess}}}}
\rput(0,3){\texttt{Chess pattern}}
\end{pspicture}
\end{center}


\newpage


\section{The command \Lcs{psmoire}}

\begin{BDef}
\Lcs{psmoire}\OptArgs\Largr{x , y}
\end{BDef}

The command \Lcs{psmoire} contains the options \nxLkeyword{type=}, \nxLkeyword{Rmax=}, \nxLkeyword{scale=}, \nxLkeyword{Alpha=}, \nxLkeyword{rotate=}, \nxLkeyword{E=}, \nxLkeyword{n=} and \nxLkeyword{T=}.

The optional argument \Largr{x , y} gives the \texttt{x} and \texttt{y} center of the image. If not chosen $(0,0)$ is taken by default.

\medskip

\begin{quote}
\begin{tabularx}{\linewidth}{ @{} l >{\ttfamily}l X @{} }\toprule
\textbf{Name}      & \textbf{Default} & \textbf{Meaning}\\\midrule
\Lkeyword{type}    & Fresnel  & The type of pattern\\
%%
\Lkeyword{rotate}  & 0        & Rotation angle of the pattern (in degrees).\\
%%
\Lkeyword{Rmax}    & 6        & For \verb+type=Gauss+ -- image dimensions: \verb+(-Rmax,-Rmax)*(Rmax,Rmax)+\\
                   &          & For \verb+type=linear+ -- \verb+2*Rmax+ is the length of the lines\\
                   &          & For \verb+type=radial+ -- maximal radii length\\
                   &          & all (in cm)\\
%%
\Lkeyword{scale}   & 1        & Scaling factor for the image\\
                   &          & available for the types: \verb+type=Fresnel/Gauss/Newton/dot/chess+\\
%%
\Lkeyword{Alpha}   & 70       & Slope of the lines (in degrees): \\
                   &          & for \verb+type=Gauss+ only\\
%%
\Lkeyword{E}       & 0.25     & x-Distance between two points on the Gaussian curve (in cm): \\
                   &          & for \verb+type=Gauss+ only\\
%%
\Lkeyword{n}       & 30       & Number of circles/lines: \\
                   &          & for \verb+type=circle+, \verb+type=linear+ only.\\
%%
\Lkeyword{T}       & 2        & Distance between two adjacent circles/lines (in mm): \\
                   &          & for \verb+type=circle+, \verb+type=linear+ only.\\
\bottomrule
\end{tabularx}
\end{quote}

\textbf{Note:}
\begin{itemize}
  \item Thickness of the lines/circles: done with the usual PSTricks key \verb+linewidth=1mm+ (for example).
  \item Color of the lines/circles: done with the usual PSTricks key \verb+linecolor=red+ (for example).
\end{itemize}
We set the type of pattern like: \texttt{type=Gauss} (for example).
{\small\begin{verbatim}
\psmoire[options,type=Gauss](x,y)
\end{verbatim}}

For the types that are not affected by \texttt{scale}, simply use the PSTricks key \verb+unit=+.

If no position coordinate is specified, the center of the image is placed at $(0,0)$. The PSTricks thickness key \verb+linewidth=+ does not affect the following types:
\verb+Fresnel+, \verb+Newton+ and \verb+radial+


\newpage


\section{The command \Lcs{addtomoirelisttype}}

\begin{BDef}
\Lcs{addtomoirelisttype}\Largb{name}
\end{BDef}

The command \Lcs{addtomoirelisttype} only comes with one mandatory argument---the name the customer chooses.

If we like to generate our own pattern we can achieve this by using the command \\
\Lcs{addtomoirelisttype}\Largb{name} within the preamble which then references to a file named
\begin{verbatim}
pst-name.pro
\end{verbatim}
where the prefix \verb+pst-+ is automatically generated. This file we need to code ourselves in PostScript language, save within the working folder and then load it within the preamble like
\begin{verbatim}
\pstheader{pst-name.pro}
\addtomoirelisttype{name}
\end{verbatim}


\subsection{How to make a custom moiré types}

\subsubsection{Sinosoidal pattern}

\[
y=a\sin(2\pi\frac{x}{T})
\]
\begin{center}
\begin{pspicture}[showgrid](-4,-3)(4,3)
\pstVerb{/amplitude 1 def /periode 6.28318530718 def}%
\psplot[plotpoints=1000,algebraic]{-4}{4}{amplitude*sin(2*Pi*x/periode)}
\end{pspicture}
\end{center}
For the grating of equidistant vertical lines we have: $x=ne$, $e$ displacement and $n$ an integer.

The ordinates of the intersection points are: $y_n=a\sin(2\pi\frac{ne}{T})$. Within the following figure, the displacement is set to 0.25.
\begin{center}
\begin{pspicture}[showgrid](-4,-3)(4,3)
\pstVerb{/amplitude 1 def /periode 6.28318530718 def}%
\psplot[plotpoints=1000,algebraic]{-4}{4}{amplitude*sin(2*Pi*x/periode)}
\psplot[plotpoints=33,algebraic,linestyle=none,showpoints]{-4}{4}{amplitude*sin(2*Pi*x/periode)}%
\multido{\r=-4+0.25}{33}{
\psline(\r,-3)(\r,3)}
\end{pspicture}
\end{center}
We determine the equations of the straight lines passing through these points and which are inclined by an angle $\alpha$ with respect to the horizontal. This is to setup with the key \texttt{Alpha=} (in degrees).

The general equation of such a line is given by: $y=x\tan(\alpha)+b$, we determine $b$ to go through one of the previous points.
\[
ne\tan(\alpha)+b=a\sin(2\pi\frac{ne}{T})
\]
and thus we get $b$.
\[
b=a\sin(2\pi\frac{ne}{T})-ne\tan(\alpha)
\]
For every value of $n$ we receive one line.
\[
y=x\tan(\alpha)+a\sin(2\pi\frac{ne}{T})-ne\tan(\alpha)
\]
We draw some lines, setting $a=1$, $T=2\pi$, $-20<n<+20$, $e=0.5$ and $\alpha=70^{\mathrm{o}}$
\begin{center}
\begin{pspicture*}[showgrid](-6,-3)(6,3)
\pstVerb{/amplitude 1 def /periode 6.28318530718 0.75 mul def
         /E1 0.25 def
         /Alpha 70 def
         /m1 {Alpha dup sin exch cos div} bind def % pente de la droite
         }%
\psplot[plotpoints=1000,algebraic]{-5}{5}{amplitude*sin(2*Pi*x/periode)}
\psplot[plotpoints=41,algebraic,linestyle=none,showpoints]{-5}{5}{amplitude*sin(2*Pi*x/periode)}%
\multido{\i=-20+1}{41}{%
\pnode(! /xi \i\space E1 mul def % x
          xi
          amplitude 360 periode div xi mul sin mul){A}
 \psdot(A)
\rput(A){\psline(! -4 -4 m1 mul)(! 4 4 m1 mul)}
  }
\end{pspicture*}
\end{center}
Now we need to code that in PostScript and name that file \texttt{pst-sin.pro} and save it within the working folder.
{\tiny\begin{verbatim}
moireDict begin
/pst-sin {
0 0 translate
2 dict begin
/A1 0.5 def % amplitude
/TRAME {
-50 E1 2 mul 50 {/n exch def
gsave
    n E1 mul unit % x
    A1 unit 360 Tr div n E1 mul mul sin mul % y
    translate
    linecolor
    linewidth
     -6 unit -6 m mul unit moveto
      6 unit 6 m mul unit lineto
     stroke
grestore
     } for
} def
Runit neg dup
Runit 2 mul dup
rectclip
    TRAME
end
} def
end
\end{verbatim}}


\newpage


This results within the following custom generated pattern.
\begin{center}
\begin{pspicture}(-5,-6)(5,6)
\psset{Rmax=5,T=2,E=0.2}
\psmoire[type=sin,rotate=2]
\psmoire[type=sin,rotate=-2]
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\begin{pspicture}(-5,-6)(5,6)
\psset{Rmax=5,T=2,E=0.2}
\psmoire[type=sin,rotate=2]
\psmoire[type=sin,rotate=-2]
\end{pspicture}
\end{verbatim}}
\textbf{Note:} Now we can use our custom generated \texttt{type=sin} with all the other options available.


\newpage


\subsubsection{Cosine pattern}

Here another PostScript code saved with the file name \texttt{pst-cosine.pro} within the working folder.
{\tiny\begin{verbatim}
moireDict begin
/pst-cosine {
/amplitud 2.5 def
/period 2 def
/cos1 [
-8 0.05 8 {/x exch def % 320 pts
 x unit
 360 x mul period div cos amplitud mul
 } for
] def
%
/drawcos {
newpath
cos1 0 get cos1 1 get moveto
0 2 cos1 length 2 sub {/i exch def
 cos1 i get cos1 i 1 add get lineto
  } for
  stroke
} def
gsave
Runit neg dup
Runit 2 mul dup
rectclip
0 -8 unit translate
nr {
 0 E1 translate
 drawcos
} repeat
grestore
} def
end
\end{verbatim}}

Setting into the preamble:
\begin{verbatim}
\pstheader{pst-cosine.pro}
\addtomoirelisttype{cosine}
\end{verbatim}

\textbf{Example 1:}

\begin{minipage}[t]{12cm}\kern0pt
\begin{pspicture}(-6,-6)(6,6)
\psset{Rmax=5,linewidth=1pt}
\psframe(-5,-5)(5,5)
\psmoire[%
type=cosine,
E=3,
n=400,
rotate=0]
\psmoire[%
type=linear,
T=0.85,
rotate=-90,
n=120,
linecolor=red](1,1)
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-6,-6)(6,6)
\psset{Rmax=5,linewidth=1pt}
\psframe(-5,-5)(5,5)
\psmoire[%
type=cosine,
E=3,
n=400,
rotate=0]
\psmoire[%
type=linear,
T=0.85,
rotate=-90,
n=120,
linecolor=red](1,1)
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\textbf{Example 2:}

\begin{minipage}[t]{12cm}\kern0pt
\begin{pspicture}(-6,-6)(6,6)
\psset{Rmax=5,linewidth=1pt}
\psframe(-5,-5)(5,5)
\psmoire[%
type=cosine,
E=3,
n=400,
rotate=0]
\psmoire[%
type=linear,
T=1.2,
rotate=100,
n=80,
linecolor=red]
\end{pspicture}
\end{minipage}
\begin{minipage}[t]{5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-6,-6)(6,6)
\psset{Rmax=5,linewidth=1pt}
\psframe(-5,-5)(5,5)
\psmoire[%
type=cosine,
E=3,
n=400,
rotate=0]
\psmoire[%
type=linear,
T=1.2,
rotate=100,
n=80,
linecolor=red]
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\section{Opacity and Blendmodes}

If we want to highlight the color of the intersecting area of the lines of two or more overlapping moiré patterns differently, we can either use \emph{opacity} or \emph{blendmodes}.


\subsection{Opacity}

In case we want to add some opacity to the lines of the moiré patterns, we just set, i. e.
\begin{verbatim}
\pstVerb{%
0.25 .setopacityalpha
}
\end{verbatim}
within the \verb+\pspicture+ environment.

Distiller users set instead:
\begin{verbatim}
\pstVerb{%
[ /ca 0.25 /CA 0.25 /SetTransparency pdfmark
}
\end{verbatim}

\textbf{Note:} The value for the opacity needs to be between 0 and 1.

\begin{center}
\begin{pspicture}(-6,-6)(6,6)
\pstVerb{%
0.25 .setopacityalpha
}
\psmoire[type=linear,linecolor=blue,linewidth=3pt,n=60]
\psmoire[type=linear,linecolor=red,linewidth=3pt,rotate=90,n=60]
\pstVerb{%
1 .setopacityalpha
}
\end{pspicture}
\end{center}
{\tiny\begin{verbatim}
\begin{pspicture}(-6,-6)(6,6)
\pstVerb{%
0.25 .setopacityalpha
}
\psmoire[type=linear,linecolor=blue,linewidth=3pt,n=60]
\psmoire[type=linear,linecolor=red,linewidth=3pt,rotate=90,n=60]
\end{pspicture}
\end{verbatim}}


\newpage


\subsection{Blendmodes}

In case we want to overlap various moiré patterns we can use the following blendmodes:
\begin{quote}
\texttt{/Lighten}, \texttt{/Darken}, \texttt{/Normal}, \texttt{/Multiply}, \texttt{/Screen}, \texttt{/Overlay}, \texttt{/ColorDodge},\\ \texttt{/ColorBurn}, \texttt{/HardLight}, \texttt{/SoftLight}, \texttt{/Difference}, \texttt{/Exclusion}, \texttt{/Saturation}, \\
\texttt{/Color}, \texttt{/Luminosity}.
\end{quote}
We just set, i. e.
\begin{verbatim}
\pstVerb{%
/Darken .setblendmode
}
\end{verbatim}
within the \verb+\pspicture+ environment.

Distiller users set instead:
\begin{verbatim}
\pstVerb{%
[ /BM /Darken /ca 1 /CA 1 /SetTransparency pdfmark
}
\end{verbatim}

\begin{center}
\begin{pspicture}(-6,-6)(6,6)
\pstVerb{%
/Darken .setblendmode
}
\psmoire[type=linear,linecolor=blue,linewidth=3pt,n=60]
\psmoire[type=linear,linecolor=green,linewidth=3pt,rotate=90,n=60]
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\begin{pspicture}(-6,-6)(6,6)
\pstVerb{%
/Darken .setblendmode
}
\psmoire[type=linear,linecolor=blue,linewidth=3pt,n=60]
\psmoire[type=linear,linecolor=green,linewidth=3pt,rotate=90,n=60]
\end{pspicture}
\end{verbatim}}


\newpage


\section{The moiré types}

\subsection{\texttt{type=Fresnel}}

The \texttt{type=Fresnel} consists of concentric circles with incrementing radii of $\sqrt{n}$. The maximum radius is given by \texttt{Rmax}. The linewidth is fixed (cannot be changed by \texttt{linewidth=}), due to the thickness of the circle varies.

\textbf{Example 1: Overlapping pattern with centers close to each other}

\begin{center}
\begin{pspicture}(-3,-3)(3,3)
\psmoire[linecolor=red,scale=0.5](-0.2,0)
\psmoire[linecolor=red,scale=0.5](0.2,0)
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\begin{pspicture}(-3,-3)(3,3)
\psmoire[linecolor=red,scale=0.5](-0.2,0)
\psmoire[linecolor=red,scale=0.5](0.2,0)
\end{pspicture}
\end{verbatim}}

\textbf{Example 2: Overlapping pattern with centers far from each other}

\begin{center}
\begin{pspicture}(-5,-3)(5,3)
\psmoire[linecolor={[rgb]{0.15 0.75 0.15}},scale=0.5](-1.5,0)
\psmoire[linecolor={[rgb]{0.15 0.75 0.15}},scale=0.5](1.5,0)
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\begin{pspicture}(-5,-3)(5,3)
\psmoire[linecolor={[rgb]{0.15 0.75 0.15}},scale=0.5](-1.5,0)
\psmoire[linecolor={[rgb]{0.15 0.75 0.15}},scale=0.5](1.5,0)
\end{pspicture}
\end{verbatim}}


\newpage


\subsection{\texttt{type=linear}}

The \texttt{type=linear} offers two more keys to be more flexible:
\begin{verbatim}
n    Number of lines -1                              Default: 30
T    Distance between the middle of two lines in mm  Default: 2
\end{verbatim}
The height of the lines is given by: \texttt{2*Rmax}, the width of the image is \texttt{n*T}

If we like a distance that is equal to the thickness of the line, we set:
\begin{verbatim}
linewidth=T/2
\end{verbatim}
If \texttt{T=2}, we set \texttt{linewidth=0.1}.

\textbf{Example 1: Basic pattern with the keys \texttt{n=} and \texttt{T=}}

\begin{minipage}[t]{8cm}\kern0pt
\begin{pspicture}(-3,-3)(3,3)
\psmoire[type=linear,n=70,T=1,Rmax=3]
\end{pspicture}
{\small\begin{verbatim}
\begin{pspicture}(-3,-3)(3,3)
\psmoire[type=linear,n=70,T=1,Rmax=3]
\end{pspicture}
\end{verbatim}}
\end{minipage}
\hfill
\begin{minipage}[t]{8cm}\kern0pt
\begin{pspicture}(-3,-3)(3,3)
\psmoire[type=linear,n=30,T=2,Rmax=3]
\end{pspicture}
{\small\begin{verbatim}
\begin{pspicture}(-3,-3)(3,3)
\psmoire[type=linear,n=30,T=2,Rmax=3]
\end{pspicture}
\end{verbatim}}
\end{minipage}

\bigskip

\textbf{Example 2: Overlapping patterns}

\begin{minipage}[t]{8cm}\kern0pt
\psscalebox{0.7}{%
\begin{pspicture}(-5,-5)(5,7)
\psset{linewidth=0.08,type=linear,n=50,Rmax=5}
\psmoire[T=2,n=55]
\psmoire[T=2.1,linecolor=red](1.8,2)
\end{pspicture}}
\end{minipage}
\hfill
\begin{minipage}[t]{8cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-5,-5)(5,7)
\psset{linewidth=0.08,type=linear,n=50,Rmax=5}
\psmoire[T=2,n=55]
\psmoire[T=2.1,linecolor=red](1.8,2)
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\subsection{\texttt{type=radial}}

The \texttt{type=radial} consists of radial rays---to be more precise, it consists of 120 sectors. The maximal radius of the sectors is given by \texttt{Rmax=}.

\textbf{Example 1: Overlapping patterns with centers close to each other}

\begin{center}
\begin{pspicture}(-4,-4)(4,4.5)
\psmoire[Rmax=4,type=radial](-0.25,0)
\psmoire[Rmax=4,type=radial](0.25,0)
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[Rmax=4,type=radial](-0.25,0)
\psmoire[Rmax=4,type=radial](0.25,0)
\end{pspicture}
\end{verbatim}}


\newpage


\subsection{\texttt{type=Bouasse}}

For some detailed information about the \texttt{type=Bouasse} as pattern, see page~\pageref{sec:Bouasse}.

\begin{center}
\psset{scale=0.7,linewidth=0.75mm}
\begin{pspicture}(-6,-5)(6,5)
\psmoire[type=Bouasse,rotate=10,Rmax=5]
\psmoire[type=Bouasse,rotate=170,Rmax=5]
\end{pspicture}

\end{center}
{\small\begin{verbatim}
\begin{pspicture}(-6,-6)(6,6)
\psmoire[type=Bouasse,rotate=10]
\psmoire[type=Bouasse,rotate=170]
\end{pspicture}
\end{verbatim}}


\newpage


\subsection{\texttt{type=circle}}

The \texttt{type=circle} offers two more keys to be more flexible:
\begin{verbatim}
n    Number of circles                            Default: 30
T    Distance between two adjacent circles in mm  Default: 2
\end{verbatim}
The key \texttt{Rmax} has no effect. The maximal width/height of the image is calculated by: \texttt{n*T}, by default: $30\cdot 2=60\,\text{mm}=6\,\text{cm}$. Another way could be to use the default values and play with the usual PSTricks key \texttt{unit=}.

The idea to make that type more flexible came from example 11.8 page 373 of the book ``\emph{The Theory of the Moiré Phenomenon}'' of Isaac Amidror.

\textbf{Example 1: Basic pattern with the keys \texttt{n=} and \texttt{T=}}

\begin{minipage}[t]{8cm}\kern0pt
\begin{pspicture}(-3,-3)(3,3)
\psmoire[type=circle,n=15,T=1]
\end{pspicture}
{\small\begin{verbatim}
\begin{pspicture}(-3,-3)(3,3)
\psmoire[type=circle,n=15,T=1]
\end{pspicture}
\end{verbatim}}
\end{minipage}
\hfill
\begin{minipage}[t]{8cm}\kern0pt
\begin{pspicture}(-3,-3)(3,3)
\psmoire[type=circle,n=15,T=2]
\end{pspicture}
{\small\begin{verbatim}
\begin{pspicture}(-3,-3)(3,3)
\psmoire[type=circle,n=15,T=2]
\end{pspicture}
\end{verbatim}}
\end{minipage}

\bigskip

\textbf{Example 2: Overlapping patterns}

The following moiré is given by a superposition of two circular gratings, however their line spacings \texttt{T1} and \texttt{T2} are slightly different and they are shifted by $+/-(x_0,y_0)$ from its origin.

\begin{minipage}[t]{8cm}\kern0pt
% With two circular patterns.
% T1 and T2 are slightly different.
% r1=m*T1 : T1=1 mm
% r2=n*T2 : T2=1.1 mm
% The moirés are: Ovals of Descartes
% demonstration of the figure 11.8 page 373 of
% "The Theory of the Moiré Phenomenon" de Isaac Amidror
% Volume 1 : Periodic Layers
% The image is found on the front cover of the book
\psscalebox{0.85}{%
\begin{pspicture}(-5,-5)(4,4.5)
\psclip{\psframe(-5,-6)(5,4)}
\psmoire[linecolor=red,type=circle,T=1,n=100](0,1)%
\endpsclip%
\rput(0.2,1.2){%
\psclip{\psframe(-4.8,-7)(5.2,3)}
\psmoire[type=circle,T=1.1,n=100]%
\endpsclip}%
\end{pspicture}}
\end{minipage}
\hfill
\begin{minipage}[t]{8cm}\kern0pt
{\footnotesize\begin{verbatim}
% With two circular patterns.
% T1 and T2 are slightly different.
% r1=m*T1 : T1=1 mm
% r2=n*T2 : T2=1.1 mm
% The moirés are: Ovals of Descartes
% demonstration of the figure 11.8 page 373 of
% "The Theory of the Moiré Phenomenon" de Isaac Amidror
% Volume 1 : Periodic Layers
% The image is found on the front cover of the book
\begin{pspicture}(-5,-5)(4,4.5)
\psclip{\psframe(-5,-6)(5,4)}
\psmoire[linecolor=red,type=circle,T=1,n=100](0,1)%
\endpsclip%
\rput(0.2,1.2){%
\psclip{\psframe(-4.8,-7)(5.2,3)}
\psmoire[type=circle,T=1.1,n=100]%
\endpsclip}%
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\textbf{Example 3: Overlapping patterns}

The following moiré is given by the superposition of two circular gratings when both gratings are centered at their origins, however their line spacings \texttt{T1} and \texttt{T2} are slightly different.

\begin{center}
\begin{pspicture*}(-5,-5)(5,5)
\psmoire[type=circle,T=1,n=100]%
\psmoire[type=circle,T=1.1,n=100,linecolor=red]%
\end{pspicture*}
\end{center}
{\small\begin{verbatim}
\begin{pspicture*}(-5,-5)(5,5)
\psmoire[type=circle,T=1,n=100]%
\psmoire[type=circle,T=1.1,n=100,linecolor=red]%
\end{pspicture*}
\end{verbatim}}


\newpage


\subsection{\texttt{type=Gauss}}

The \texttt{type=Gauss} offers two keys to be more flexible:
\begin{verbatim}
Alpha  Slope of the lines             Default: 70
E      x-distance between two points
       on the Gaussian curve          Default: 0.25
\end{verbatim}
The key \texttt{Alpha=} is self-explanatory---see the following example. For the key \texttt{E=}, see the sketch of the Gaussian curve on page~\pageref{sec:Gauss}.

\textbf{Example 1: Basic pattern}

\begin{minipage}[t]{8cm}\kern0pt
\begin{pspicture}(-4,-4)(4,4)
\rput(-3.8,-4){%
\psline[linecolor=red,linewidth=2pt](0;0)(6;50)
\psarc[linecolor=red,linewidth=2pt]{->}(0,0){2}{0}{50}
\rput(1.25;25){\textcolor{red}{\texttt{\textbf{Alpha}}}}
}
\psmoire[Rmax=4,type=Gauss,Alpha=50]
\end{pspicture}
{\small\begin{verbatim}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[Rmax=4,type=Gauss,Alpha=50]
\end{pspicture}
\end{verbatim}}
\end{minipage}
\hfill
\begin{minipage}[t]{8cm}\kern0pt
\begin{pspicture}(-4,-4)(4,4)
\psmoire[Rmax=4,type=Gauss,Alpha=50,E=0.5]
\end{pspicture}
{\small\begin{verbatim}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[Rmax=4,type=Gauss,Alpha=50,E=0.5]
\end{pspicture}
\end{verbatim}}
\end{minipage}

\bigskip

\textbf{Example 2: Overlapping patterns}

\begin{minipage}[t]{8cm}\kern0pt
\psset{linewidth=0.5mm,Rmax=4}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[type=Gauss,rotate=-5,linecolor=red]
\psmoire[type=Gauss,rotate=5]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{8cm}\kern0pt
{\small\begin{verbatim}
\psset{linewidth=0.5mm,Rmax=4}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[type=Gauss,rotate=-5,linecolor=red]
\psmoire[type=Gauss,rotate=5]
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\subsection{\texttt{type=square}}

The \texttt{type=square} consists of equidistant squares with a distance 2 mm each.

\textbf{Example 1:}

The following moiré is given by a superposition of two square gratings when both gratings are rotated by $+/-5^\circ$ around its origin.

\begin{center}
\psset{linewidth=1mm,scale=0.6}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[type=square,rotate=-5]
\psmoire[type=square,rotate=5]
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\psset{linewidth=1mm,scale=0.6}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[type=square,rotate=-5]
\psmoire[type=square,rotate=5]
\end{pspicture}
\end{verbatim}}


\newpage


\subsection{\texttt{type=Newton}}

The \texttt{type=Newton} consists of concentric squares with incrementing side length of $\sqrt{n}$. The maximum side length is given by \texttt{Rmax}. The linewidth is fixed (cannot be changed by \texttt{linewidth=}), due to the thickness of the squares varies.

\textbf{Example 1:}

The following moiré is given by a superposition of two Newton gratings when both gratings are rotated by $+/-2.5^\circ$ around its origin.

\begin{center}
\psset{linewidth=0.5mm,scale=0.5}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[type=Newton,rotate=-2.5]
\psmoire[type=Newton,rotate=2.5]
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\psset{linewidth=0.5mm,scale=0.5}
\begin{pspicture}(-4,-4)(4,4)
\psmoire[type=Newton,rotate=-2.5]
\psmoire[type=Newton,rotate=2.5]
\end{pspicture}
\end{verbatim}}


\newpage


\subsection{\texttt{type=dot}}

The \texttt{type=dot} consists of dots bordered within a square of side lengths \texttt{Rmax*Rmax}. The \texttt{dotstyle=} and \texttt{dotsize=} can be individually setup. Its colors can be chosen by the usual PSTricks key \texttt{linecolor}.

\textbf{Example 1:}

The following moiré is given by a superposition of two dot gratings when both gratings are rotated by $+/-2.5^\circ$ around its origin.

\begin{center}
\psset{Rmax=4}
\begin{pspicture}(-4,-4)(4,5)
\psmoire[type=dot,linecolor=blue,rotate=-2.5]
\psmoire[type=dot,rotate=2.5,linecolor=red]
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\psset{Rmax=4}
\begin{pspicture}(-5,-5)(5,5)
\psmoire[type=dot,linecolor=blue,rotate=-2.5]
\psmoire[type=dot,rotate=2.5,linecolor=red]
\end{pspicture}
\end{verbatim}}


\newpage


\subsection{\texttt{type=chess}}

The \texttt{type=chess} consists of squares bordered within a square of side lengths \texttt{Rmax*Rmax}. The \texttt{dotstyle=} and \texttt{dotsize=} can be individually setup. Its colors can be chosen by the usual PSTricks key \texttt{linecolor}.

\textbf{Example 1:}

The following moiré is given by a superposition of two chess gratings when both gratings are rotated by $+/-5^\circ$ around its origin.

\begin{center}
\psset{Rmax=4,dotstyle=square*,dotsize=0.25cm,linecolor={[cmyk]{0 0.81 1 0.6}}}
\begin{pspicture}(-4,-4)(4,5)
\psmoire[type=chess,rotate=-5]
\psmoire[type=chess,rotate=5]
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\psset{Rmax=4,dotstyle=square*,dotsize=0.25cm}
\begin{pspicture}(-4,-4)(4,5)
\psmoire[type=chess,rotate=-5]
\psmoire[type=chess,rotate=5]
\end{pspicture}
\end{verbatim}}


\newpage


\section{Examples of combined moiré patterns}

\textbf{Example 1:}

\begin{minipage}[t]{6cm}\kern0pt
\psset{Rmax=8,linewidth=0.5mm,scale=0.5,
linecolor={[rgb]{0.357 0.525 0.13}}}
\begin{pspicture}(-5,-5)(5,5)
\rput(0,4.75){\texttt{type=Fresnel + type=linear}}
\psmoire[type=Fresnel]
\psmoire[type=linear,n=40]
\psmoire[type=linear,n=41](-0.1,0)
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\footnotesize\begin{verbatim}
\psset{Rmax=8,linewidth=0.5mm,scale=0.5,
linecolor={[rgb]{0.357 0.525 0.13}}}
\begin{pspicture}(-5,-5)(5,5)
\rput(0,4.75){\texttt{type=Fresnel + type=linear}}
\psmoire[type=Fresnel]
\psmoire[type=linear,n=40]
\psmoire[type=linear,n=41](-0.1,0)
\end{pspicture}
\end{verbatim}}
\end{minipage}

\bigskip

\textbf{Example 2:}

\begin{minipage}[t]{6cm}\kern0pt
\psset{Rmax=8,linewidth=0.5mm,scale=0.5}
\begin{pspicture}(-5,-5)(5,5)
\rput(0,4.75){\texttt{type=Fresnel + type=square}}
\psmoire[type=Fresnel,linecolor=orange]
\psmoire[type=square,linecolor=gray]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\footnotesize\begin{verbatim}
\psset{Rmax=8,linewidth=0.5mm,scale=0.5}
\begin{pspicture}(-5,-5)(5,5)
\rput(0,4.75){\texttt{type=Fresnel + type=square}}
\psmoire[type=Fresnel,linecolor=orange]
\psmoire[type=square,linecolor=gray]
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\textbf{Example 3:}

\begin{minipage}[t]{6cm}\kern0pt
\psset{Rmax=8,linewidth=0.5mm,scale=0.5}
\begin{pspicture}(-5,-5)(5,5)
\rput(0,4.75){\texttt{type=Newton + type=square}}
\psmoire[type=Newton,linecolor=blue,rotate=5]
\psmoire[type=square,linecolor=cyan,rotate=-5]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\footnotesize\begin{verbatim}
\psset{Rmax=8,linewidth=0.5mm,scale=0.5}
\begin{pspicture}(-5,-5)(5,5)
\rput(0,4.75){\texttt{type=Newton + type=square}}
\psmoire[type=Newton,linecolor=blue,rotate=5]
\psmoire[type=square,linecolor=cyan,rotate=-5]
\end{pspicture}
\end{verbatim}}
\end{minipage}

\bigskip

\textbf{Example 4:}

\begin{minipage}[t]{6cm}\kern0pt
\psset{Rmax=8,scale=0.5}
\begin{pspicture}(-5,-5)(5,5)
\pstVerb{%
/Multiply .setblendmode
}
\rput(0,4.75){\texttt{type=Fresnel + type=Newton}}
\psmoire[%
type=Fresnel,
linecolor=gray
](-0.05,0)
\psmoire[%
type=Newton,
linecolor=gray!30,
rotate=5
](0.05,0)
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\footnotesize\begin{verbatim}
\psset{Rmax=8,scale=0.5}
\begin{pspicture}(-5,-5)(5,5)
\pstVerb{%
/Multiply .setblendmode
}
\rput(0,4.75){\texttt{type=Fresnel + type=Newton}}
\psmoire[%
type=Fresnel,
linecolor=gray
](-0.05,0)
\psmoire[%
type=Newton,
linecolor=gray!30,
rotate=5
](0.05,0)
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


These following rotating moirés were obtained with the use of the \texttt{pst-lens} package. It is the reproduction, with the tools of PSTricks, of the image 6, page 137 of the book ``\textit{Les phénomènes naturels}'' of the Library \textit{Pour la Science}, Berlin (1978). This image is accompanied by the following comment:
\begin{quote}\itshape
<<~Ces moirés tournants apparaissent quand les lentilles placées sur une trame et observées avec une autre trame identique à la première. La grosse lentille (convergente) réduit la trame inférieure, tandis que la petite lentille (divergente) la grossit. En conséquence, les moirés obtenus ont des sens de rotation opposés. Une figure de moiré ondulée traduit la présence d'aberrations optiques dans la lentille.~>>
\end{quote}

\textbf{Animation:} Big lens: magnification of 1.2, small lens: magnification of 0.8

\begin{center}
\begin{animateinline}[controls,palindrome,
                     begin={\begin{pspicture}(-7,-7)(7,7)},
                     end={\end{pspicture}}]{10}% 10 image/s
\multiframe{20}{i=-10+1}{%
\psset{LensHandle=false,LensShadow=false}
\psset{linecolor=red,linewidth=0.1,type=linear,n=60}
\psmoire%
\PstLens[LensMagnification=1.2,LensSize=2](1,1.5){\psmoire}
\PstLens[LensMagnification=0.8,LensSize=1.5](-2,-2){\psmoire}
\psmoire[linecolor=black,rotate=\i]}
\end{animateinline}
\end{center}
{\tiny\begin{verbatim}
\begin{animateinline}[controls,palindrome,
                     begin={\begin{pspicture}(-7,-7)(7,7)},
                     end={\end{pspicture}}]{10}% 10 image/s
\multiframe{20}{i=-10+1}{%
\psset{LensHandle=false,LensShadow=false}
\psset{linecolor=red,linewidth=0.1,type=linear,n=60}
\psmoire%
\PstLens[LensMagnification=1.2,LensSize=2](1,1.5){\psmoire}
\PstLens[LensMagnification=0.8,LensSize=1.5](-2,-2){\psmoire}
\psmoire[linecolor=black,rotate=\i]}
\end{animateinline}
\end{verbatim}}


\newpage


\section{Random moirés}

\begin{figure}[h]
  \caption{Circular: a=1, b=1 $\theta=5$}
  \centering
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)
\psRandomDotPatterns[coefficients=1 1 5,linecolor=red,fillcolor=blue]
\end{pspicture}
\label{circular}
\end{figure}
\begin{quote}\itshape
``The moiré patterns are formed from the superimposition of two random dot patterns: an original and a second pattern generated following a linear or nonlinear transformation of the original. Though each set is random, a variety of different spatial patterns such as circles, spirals, hyperbolae, can be generated by introducing correlations between the two sets of dots. In this image~\ref{circular}, for each dot there is a corresponding ``partner'' dot that lies along the circumference of a circle centered at the point of rotation of the two images. The visual system is able to decode these correlations, thereby perceiving the underlying global transformation.''
\end{quote}
\begin{center}
\url{http://www.scholarpedia.org/article/Glass_patterns}
\end{center}
The article mentioned above contains a history of the physiological interpretations of the perception of moiré patterns and we reproduced the beginning of the paragraph.

The authors Leon Glass and Matthew A. Smith propose the following transformations:
\begin{align*}
x'&= ax \cos \theta - by\sin \theta\\
y'&= ax \sin \theta + by\cos \theta
\end{align*}
which give the following Eigenvalues:
\begin{equation*}
\lambda_\pm = \frac{(a+b)\cos\theta\pm\sqrt{(a-b)^2-(a+b)^2 \sin^2\theta}}{2}
\end{equation*}
Another article of Leon Glass:
\begin{center}
\url{http://www.medicine.mcgill.ca/physio/glasslab/pub_pdf/dots_mi_2002.pdf}
\end{center}
We added the terms $(x_0,y_0)$ to be able to also illustrate translations:
\begin{align*}
x' &= ax \cos \theta - by\sin \theta +x_0 \\
y' &= ax \sin \theta + by\cos \theta +y_0
\end{align*}
$\theta$ is the angle of rotation between the two layers. The values of $a$ and $b$ are scaling factors respectively for $x$ and $y$.


\subsection{The command \Lcs{psRandomDotPatterns}}

\begin{BDef}
\Lcs{psRandomDotPatterns}\OptArgs
\end{BDef}

The command \Lcs{psRandomDotPatterns} contains the options \nxLkeyword{NumberDots=}, \nxLkeyword{coefficients=}, \nxLkeyword{srand=}, \nxLkeyword{layer=} and \nxLkeyword{revlayer=}.

\medskip

\begin{quote}
\begin{tabularx}{\linewidth}{ @{} l >{\ttfamily}l X @{} }\toprule
\textbf{Name}      & \textbf{Default} & \textbf{Meaning}\\\midrule
\Lkeyword{NumberDots}    & 2000  & Number of randomly arranged dots.\\
%%
\Lkeyword{coefficients}  & 1.05 1.05 0 0 0  & $a$  $b$ $\theta$ $x_0$ $y_0$. If the two last values are omitted (they are responsible for an eventual translation), they are automatically set to 0.\\
%%
\Lkeyword{srand}      & 10        & Random seed of PostScipt for the randomly arranged dots.\\
%%
\Lkeyword{layer}      & true      & If set to \texttt{false}, the first layer is hidden.\\
%%
\Lkeyword{revlayer}   & true      & If set to \texttt{false}, the second layer is hidden.\\
\bottomrule
\end{tabularx}
\end{quote}

\textbf{Note:} We can draw superposed layers within a given square of 10 cm length. We can scale the image with the PSTricks key \verb+unit=+.

The radius of the dots is random, it is between 0 and 2 pt. The color of the points of the first layer is fixed with the PSTricks key \verb+linecolor=+ and the color of the second layer with the PSTricks key \verb+fillcolor=+.


\newpage


\textbf{Example 1: Translation} ($a=1$, $b=1$, $\theta=0$, $x_0=5$, $y_0=5$)

\begin{minipage}[t]{9cm}\kern0pt
\begin{pspicture}(-4.5,-4.5)(4.5,4.5)
\psRandomDotPatterns[coefficients=1 1 0 5 5,unit=0.9]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)
\psRandomDotPatterns[%
coefficients=1 1 0 5 5
]
\end{pspicture}
\end{verbatim}}
\end{minipage}

\bigskip
\bigskip

\textbf{Example 2: Radial} ($a=1.05$, $b=1.05$, $\theta=0$)

\begin{minipage}[t]{9cm}\kern0pt
\begin{pspicture}(-4.5,-4.5)(4.5,4.5)
  \psRandomDotPatterns[unit=0.9]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)
  \psRandomDotPatterns
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\textbf{Example 3: Elliptic} ($a=1.05$, $b=0.95$, $\theta=5$)

\begin{minipage}[t]{9cm}\kern0pt
\begin{pspicture}(-4.5,-4.5)(4.5,4.5)
\psRandomDotPatterns[coefficients=1.05 0.95 5,unit=0.9]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)
\psRandomDotPatterns[coefficients=1.05 0.95 5]
\end{pspicture}
\end{verbatim}}
\end{minipage}

\bigskip
\bigskip

\textbf{Example 4: Spiral} ($a=1$, $b=1.05$, $\theta=5$)

\begin{minipage}[t]{9cm}\kern0pt
\begin{pspicture}(-4.5,-4.5)(4.5,4.5)
\psframe*(-4.5,-4.5)(4.5,4.5)
\psRandomDotPatterns[coefficients=1 1.05 5,linecolor=white,fillcolor=white,unit=0.9]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)
\psframe*(-5.5,-5.5)(5.5,5.5)
\psRandomDotPatterns[%
coefficients=1 1.05 5,
linecolor=white,
fillcolor=white
]
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\textbf{Example 5: Hyperbolic} ($a=0.95$, $b=1.05$, $\theta=0$)

\begin{minipage}[t]{9cm}\kern0pt
\begin{pspicture}(-4.5,-4.5)(4.5,4.5)
\psRandomDotPatterns[coefficients=0.95 1.05 0,unit=0.9]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{7.5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-5.5,-5.5)(5.5,5.5)
\psRandomDotPatterns[coefficients=0.95 1.05 0]
\end{pspicture}
\end{verbatim}}
\end{minipage}


\subsubsection{The keys \texttt{layer} and \texttt{revlayer}}

\begin{minipage}[t]{0.45\linewidth}\kern0pt
\begin{pspicture}(-3.5,-4.5)(3.5,3.5)
\psframe*[linecolor=yellow](-3.5,-3.5)(3.5,3.5)
\psRandomDotPatterns[%
unit=0.7,
revlayer=false,
coefficients=1 1.05 5,
linecolor=red]
\rput(0,-4){coefficients=1 1.05 5, \textbf{revlayer=false}}
\end{pspicture}
{\footnotesize\begin{verbatim}
\begin{pspicture}(-3.5,-4.5)(3.5,3.5)
\psframe*[linecolor=yellow](-3.5,-3.5)(3.5,3.5)
\psRandomDotPatterns[%
unit=0.7,
revlayer=false,
coefficients=1 1.05 5,
linecolor=red]
\rput(0,-4){%
coefficients=1 1.05 5, 
\textbf{revlayer=false}}
\end{pspicture}
\end{verbatim}}
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\linewidth}\kern0pt
\begin{pspicture}(-3.5,-4.5)(3.5,3.5)
\psframe*[linecolor=yellow](-3.5,-3.5)(3.5,3.5)
\psRandomDotPatterns[%
unit=0.7,
layer=false,
coefficients=1 1.05 5,
fillcolor=red]
\rput(0,-4){coefficients=1 1.05 5, \textbf{layer=false}}
\end{pspicture}
{\footnotesize\begin{verbatim}
\begin{pspicture}(-3.5,-4.5)(3.5,3.5)
\psframe*[linecolor=yellow](-3.5,-3.5)(3.5,3.5)
\psRandomDotPatterns[%
unit=0.7,
layer=false,
coefficients=1 1.05 5,
fillcolor=red]
\rput(0,-4){%
coefficients=1 1.05 5, 
\textbf{layer=false}}
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


Both layers superposed.

\begin{pspicture}(-5.5,-7)(5.5,6)
\psframe*[linecolor=yellow](-5.5,-5.5)(5.5,5.5)
\psRandomDotPatterns[linecolor=red,fillcolor=red,coefficients=1 1.05 5]
\rput(0,-5.75){coefficients=1 1.05 5}
\end{pspicture}
{\small\begin{verbatim}
\begin{pspicture}(-5.5,-5.5)(5.5,6)
\psframe*[linecolor=yellow](-5.5,-5.5)(5.5,5.5)
\psRandomDotPatterns[%
coefficients=1 1.05 5
linecolor=red,
fillcolor=red]
\rput(0,-6){coefficients=1 1.05 5}
\end{pspicture}
\end{verbatim}



\newpage


\subsection{The command \Lcs{psRandomDot}}

Emin Gabrielyan presents on
\begin{center}
\url{https://docs.switzernet.com/people/emin-gabrielyan/070212-random-moire/}
\end{center}
another amazing moiré pattern (his second example).

A plate perforated with holes (the \emph{revealing layer}), is placed on top of a fixed layer (the \emph{base layer}) filled with the digit ``2'', and then rotated.

These holes of the revealing layer are arranged randomly, and the digits ``2'' are arranged on the base layer at exactly the same places (just larger than the holes and rotated by -90 degrees). Both layers are therefore correlated---this is the necessary condition for the existence of this random moiré phenomenon.

Why do we see the digit ``2'' as a \emph{halo} with a magnifying effect as a function of the angle---upright or upside down according to the sign of the angle? The holes of the revealing layer cover the digits ``2'' of the base layer and these superposed parts reconstruct an enlarged digit ``2''; what is the explanation of this phenomenon?


\bigskip

\begin{BDef}
\Lcs{psRandomDot}\OptArgs\Largr{x , y}
\end{BDef}

The command \Lcs{psRandomDot} contains the options \nxLkeyword{hole=}, \nxLkeyword{r=}, \nxLkeyword{p=}, \nxLkeyword{k=}, \nxLkeyword{symbole=}, \nxLkeyword{rotate=}, \nxLkeyword{PSfont=}, \nxLkeyword{fontsize=}, \nxLkeyword{vadjust=} and \nxLkeyword{hadjust=}.

The optional argument \Largr{x , y} sets up the dimensions \texttt{x} and \texttt{y} of the image. If not chosen $(10,10)$ is taken by default.

\medskip

\begin{quote}
\begin{tabularx}{\linewidth}{ @{} l >{\ttfamily}l X @{} }\toprule
\textbf{Name}      & \textbf{Default} & \textbf{Meaning}\\\midrule
\Lkeyword{hole}    & round  & Types of holes: hole=round (circle holes), hole=square (square holes)\\
%%
\Lkeyword{r}    & 0.5  & Radius for circle/side length of square of the holes (in pt)\\
%%
\Lkeyword{p}  & 4        & Distance between the holes (in pt).\\
%%
\Lkeyword{rotate}    & 0   & Angle of rotation between base layer and revealing layer (in degrees) \\
&                           & Typical values: -2<rotate<2\\
%%
\Lkeyword{k}   & 0.2        & Factor for the dispersion of the holes\\
%%
\Lkeyword{symbole}   & 2       & Digit or letter for the base layer\\
%%
\Lkeyword{PSfont}       & Helvetica-Bold     & Font family of PS fonts\\
%%
\Lkeyword{fontsize}       & 4.7       & Font size (in pt)\\
%%
\Lkeyword{vadjust}       & -1.5        & Vertical adjustment of the superposed image\\
%%
\Lkeyword{hadjust}       & 0        & Horizontal adjustment of the superposed image\\
\bottomrule
\end{tabularx}
\end{quote}

\textbf{Principle:}

\begin{enumerate}
\item We draw a path (newpath) that starts along a square (or a rectangle) anti-clockwise.
\item On a 2D grid, where points are setup with a constant distance of \texttt{p}, the centers of the circle/square shaped holes (with dimensions \texttt{r}) are then randomly distributed around each of the points on the grid within a circle with the \emph{distribution radius} $\rho = k\cdot p$. (The bigger \texttt{k}, the more disorder. The bigger \texttt{p}, the less points inside the given grid of a square/rectangle base layer.)
\end{enumerate}

\textbf{Additional Remark:} For a list of some more \emph{PostScript font names}, look up the appendix on page~\pageref{sec:PSF}.


\newpage


\textbf{Example 1:}

\begin{minipage}[t]{11cm}\kern0pt
\begin{pspicture}(-5,-5.5)(5,5)
\psRandomDot[
r=0.5,
p=4,
k=0.2,
symbole=2,
rotate=-1,
PSfont=Helvetica-Bold,
fontsize=4.7,
vadjust=-1.5,
hadjust=0,
hole=round](10,10)
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-5,-5.5)(5,5)
\psRandomDot[
r=0.5,
p=4,
k=0.2,
symbole=2,
rotate=-1,
PSfont=Helvetica-Bold,
fontsize=4.7,
vadjust=-1.5,
hadjust=0,
hole=round](10,10)
\end{pspicture}
\end{verbatim}}
\end{minipage}

\textbf{Example 2:}

\begin{minipage}[t]{11cm}\kern0pt
\begin{pspicture}(-5,-5.5)(5,5)
\psRandomDot[
r=0.5,
p=4,
k=0.2,
symbole=p,
rotate=-1,
PSfont=Symbol,
fontsize=4.7,
vadjust=-1.5,
hadjust=0,
hole=round](10,10)
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{5cm}\kern0pt
{\small\begin{verbatim}
\begin{pspicture}(-5,-5.5)(5,5)
\psRandomDot[
r=0.5,
p=4,
k=0.2,
symbole=p,
rotate=-1,
PSfont=Symbol,
fontsize=4.7,
vadjust=-1.5,
hadjust=0,
hole=round](10,10)
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\section{Glass-patterns}

\emph{Glass-patterns} result from a superposition of two random dotted layers---a first original layer and a second layer which is a transformed layer of the original.

These patterns received their names from Leon Glass.


\subsection{The command \Lcs{psGlassPattern}}

\begin{BDef}
\Lcs{psGlassPattern}\OptArgs
\end{BDef}

The command \Lcs{psGlassPattern} contains the options \nxLkeyword{function=} and \nxLkeyword{layers=true/false}.

\medskip

\begin{quote}
\begin{tabularx}{\linewidth}{ @{} l >{\ttfamily}l X @{} }\toprule
\textbf{Name}      & \textbf{Default} & \textbf{Meaning}\\\midrule
\Lkeyword{function}    & 5 r mul t 5 mul sin neg   & The equation of the function\\
                       & 0.5 mul 1 add mul 2.5 sub  & \\
                       && \texttt{r} and \texttt{t} are the variables of the function in polar coordinates\\
                       && \verb-r=sqrt(x^2+y^2)-, \verb+t=theta+\\
%%
\Lkeyword{layers}    & true  & Both layers are shown. If set to \texttt{false}, only the revealing layer with the hidden shape of the function is shown.\\
\bottomrule
\end{tabularx}
\end{quote}

\textbf{Note:} The dimensions of the layers are 15 cm x 15 cm and can be modified with \texttt{unit=}.

\bigskip

\textbf{Remarks:}
\begin{itemize}
\item The key \texttt{function=} is the equation of a function in polar coordinates with the variables \texttt{r} (radius coordinate) and \texttt{t}, which is an angle in degrees.

    The star-like functions are of the type: \texttt{z=r*(1-0.5*cos(theta))}, with each value of \texttt{z} there corresponds a star-like function with the equation (in polar coordinates):

    \texttt{r=z/(1-0.5*cos(theta))}

    The equation of a function can either be entered with RVN (Reverse Polish Notation = PostScript notation) or when the PSTricks key \texttt{algebraic=true} is set, it is possible to enter the equation in algebraic notation (therefore we need to transform the variable \texttt{t} from degrees into radians which can be done with the substitution \texttt{t -> t*Pi/180}.
\item If the key \texttt{layers=false} is set to false, only the layer with the hidden shape of the function is shown.
\item The colors of the randomly arranged dots can be chosen with the PSTricks keys \texttt{linecolor=} (for the first layer) and \texttt{fillcolor=} (for the second layer).
\item The size and shape of the dots can be setup with the PSTricks keys \texttt{dotsize=} and \texttt{dotstyle=}.
\end{itemize}


\newpage


\textbf{Example 1:}

Here a citation from Isaac Amidror from his book:

``The Theory of the Moiré Phenomenum'', Volume II: Aperiodic Layers, \textbf{3-18: Synthesis of a layer superposition having a predefined fixed locus.}

\begin{quote}\itshape
``Design layer transformations $\mathbf{g}_1(x,y)$ and $\mathbf{g}_2(x,y)$ that will produce in the superposition of two initially identical random screens a fixed locus consisting of a star-like curve that surrounds the origin as shown in the figure on the front cover of this book. Hint: In this case, you may consider a top-opened conic surface having star-like level lines, such as $z=r(1+0.5\cos5\theta)$, or, possibly, $z=r/(1+0.5\cos5\theta)$, which gives a slightly different star. You may adjust the orientation of the star by replacing $\cos$ by $\sin$ or by $-\sin$, as seems suitable. In order to have this surface intersect the $x,y$ plane along a star, you need to lower it by some constant $z_0$: $z=r(1+0.5\cos5\theta)-z_0$. But if you wish to obtain a more complex surface that intersects the $x,y$ plane on a family of concentric stars, you may consider a surface such as: $z=\sin(r(1+0.5\cos5\theta))$.''
\end{quote}

\begin{center}
\begin{pspicture}(-7,-7)(7,7)
\psframe*[linecolor=orange](-7,-7)(7,7)
% z=5*r*(1-0.5*sin(5*t*Pi/180))-2.5
\psGlassPattern[unit=0.8,linecolor=red]
\end{pspicture}
\end{center}
{\small\begin{verbatim}
\begin{pspicture}(-7,-7)(7,7)
\psframe*[linecolor=orange](-7,-7)(7,7)
% z=5*r*(1-0.5*sin(5*t*Pi/180))-2.5
\psGlassPattern[unit=0.8,linecolor=red]
\end{pspicture}
\end{verbatim}}


\newpage


\textbf{Example 2:}

\begin{minipage}[t]{11cm}\kern0pt
\begin{pspicture}(-5,-5)(5,5)
\psframe*[linecolor=red](-5,-5)(5,5)
% in algebraic notation
% t in degrees;
% arguments of sin and cos in radians
% convert t -> t*Pi/180
\psGlassPattern[%
unit=0.65,
dotsize=1pt,
dotstyle=square,
linecolor={[rgb]{0 0 0.5}},
algebraic,
function=5*r*(1-0.5*cos(7*t*Pi/180))-2.5]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{6cm}\kern0pt
{\footnotesize\begin{verbatim}
\begin{pspicture}(-5,-5)(5,5)
\psframe*[linecolor=red](-5,-5)(5,5)
% in algebraic notation
% t in degrees;
% arguments of sin and cos in radians
% convert t -> t*Pi/180
\psGlassPattern[%
unit=0.65,
dotsize=1pt,
dotstyle=square,
linecolor={[rgb]{0 0 0.5}},
algebraic,
function=5*r*(1-0.5*cos(7*t*Pi/180))-2.5]
\end{pspicture}
\end{verbatim}}
\end{minipage}

\medskip

\textbf{Example 3:}

\begin{minipage}[t]{11cm}\kern0pt
\begin{pspicture}(-5,-5)(5,5)
\psframe*[linecolor=cyan](-5,-5)(5,5)
% in algebraic notation
% t in degrees;
% arguments of sin and cos in radians
% convert t -> t*Pi/180
\psGlassPattern[%
unit=0.65,
dotsize=1pt,
dotstyle=square*,
linecolor=black,
fillcolor=cyan,
algebraic,
function=5*r/(1-0.75*sin(5*t*Pi/180))-2.5]
\end{pspicture}
\end{minipage}
\hfill
\begin{minipage}[t]{6cm}\kern0pt
{\footnotesize\begin{verbatim}
\begin{pspicture}(-5,-5)(5,5)
\psframe*[linecolor=cyan](-5,-5)(5,5)
% in algebraic notation
% t in degrees;
% arguments of sin and cos in radians
% convert t -> t*Pi/180
\psGlassPattern[%
unit=0.65,
dotsize=1pt,
dotstyle=square*,
linecolor=black,
fillcolor=cyan,
algebraic,
function=5*r/(1-0.75*sin(5*t*Pi/180))-2.5]
\end{pspicture}
\end{verbatim}}
\end{minipage}


\newpage


\section{Animations}

Some interactive moiré JavaScript based applications can be found on:
\begin{center}
\url{https://melusine.eu.org/syracuse/G/pstricks/pst-moire/moirej/}
\end{center}

The following animations are all generated with the \texttt{animate} package of Alexander Grahn.
\begin{center}
\url{https://ctan.org/pkg/animate}
\end{center}

\textbf{Animation 1:}

\begin{center}
\begin{animateinline}[%
    controls,palindrome,
    begin={\begin{pspicture}(-6,-6)(6,6)},
    end={\end{pspicture}}
    ]{5}% 5 image/s
\multiframe{36}{i=0+1}{%
\psmoire[type=Newton,rotate=-\i]%
\psmoire[type=Newton,rotate=\i]%
}
\end{animateinline}
\end{center}
{\small\begin{verbatim}
\begin{animateinline}[%
    controls,palindrome,
    begin={\begin{pspicture}(-6,-6)(6,6)},
    end={\end{pspicture}}
    ]{5}% 5 image/s
\multiframe{36}{i=0+1}{%
\psmoire[type=Newton,rotate=-\i]%
\psmoire[type=Newton,rotate=\i]%
}
\end{animateinline}
\end{verbatim}


\newpage


\textbf{Animation 2:}

\begin{center}
\begin{animateinline}[%
    controls,palindrome,
    begin={\begin{pspicture}(-6,-6)(6,6)},
    end={\end{pspicture}}
    ]{10}% 10 image/s
\multiframe{36}{r=0+0.1}{%
\psframe*[linecolor=black](-6,-6)(6,6)
\psmoire[type=linear,rotate=-\r,linewidth=0.05,linecolor=yellow,n=60](0,0)%
\psmoire[type=linear,rotate=\r,linewidth=0.15,linecolor=black,n=60](0,0)%
\psframe[linecolor=yellow,linewidth=5pt](-6,-6)(6,6)
}
\end{animateinline}
\end{center}
{\small\begin{verbatim}
\begin{animateinline}[%
    controls,palindrome,
    begin={\begin{pspicture}(-6,-6)(6,6)},
    end={\end{pspicture}}
    ]{10}% 10 image/s
\multiframe{36}{r=0+0.1}{%
\psframe*[linecolor=black](-6,-6)(6,6)
\psmoire[type=linear,rotate=-\r,linewidth=0.05,linecolor=yellow,n=60](0,0)%
\psmoire[type=linear,rotate=\r,linewidth=0.15,linecolor=black,n=60](0,0)%
\psframe[linecolor=yellow,linewidth=5pt](-6,-6)(6,6)
}
\end{animateinline}
\end{verbatim}


\newpage


\textbf{Animation 3:}

\begin{center}
\begin{animateinline}[%
    controls,palindrome,
    begin={\begin{pspicture}(-6,-6)(6,6)},
    end={\end{pspicture}}
    ]{5}% 5 image/s
\multiframe{20}{r=0+0.025}{%
\psset{linewidth=2.5pt}
\psmoire[type=circle,linecolor=moire1](0,\r)
\psmoire[type=circle,linecolor=moire2](0,-\r)
\psmoire[type=circle,linecolor=moire3](\r,0)
\psmoire[type=circle,linecolor=moire4](-\r,0)
}
\end{animateinline}
\end{center}
{\small\begin{verbatim}
\definecolor{moire1}{rgb}{0.98,0.89,0.56}
\definecolor{moire2}{rgb}{0.357,0.525,0.13}
\definecolor{moire3}{rgb}{0.2,0.05,0.015}
\definecolor{moire4}{rgb}{0.070.41 0.255}
\begin{animateinline}[%
    controls,palindrome,
    begin={\begin{pspicture}(-6,-6)(6,6)},
    end={\end{pspicture}}
    ]{5}% 5 image/s
\multiframe{20}{r=0+0.025}{%
\psset{linewidth=2.5pt}
\psmoire[type=circle,linecolor=moire1](0,\r)
\psmoire[type=circle,linecolor=moire2](0,-\r)
\psmoire[type=circle,linecolor=moire3](\r,0)
\psmoire[type=circle,linecolor=moire4](-\r,0)
}
\end{animateinline}
\end{verbatim}}


\newpage


\textbf{Animation 4:}

\begin{center}
\begin{animateinline}[%
    controls,palindrome,
    begin={\begin{pspicture}(-6,-6)(6,6)},
    end={\end{pspicture}}
    ]{5}% 5 image/s
\multiframe{30}{r=0+0.025}{%
\psset{linewidth=1pt}
\psmoire[type=radial,linecolor=red](\r,0)
\psmoire[type=radial,linecolor=green](-\r,0)
\psmoire[type=radial,linecolor=blue](0,-\r)
}
\end{animateinline}
\end{center}
{\small\begin{verbatim}
\begin{animateinline}[%
    controls,palindrome,
    begin={\begin{pspicture}(-6,-6)(6,6)},
    end={\end{pspicture}}
    ]{5}% 5 image/s
\multiframe{30}{r=0+0.025}{%
\psset{linewidth=1pt}
\psmoire[type=radial,linecolor=red](\r,0)
\psmoire[type=radial,linecolor=green](-\r,0)
\psmoire[type=radial,linecolor=blue](0,-\r)
}
\end{animateinline}
\end{verbatim}}


\newpage


\textbf{Animation 5:}

The reason to finally setup this PSTricks package came from a post card ``\textit{turn the top part}''---bought years ago in a boutique of the \emph{Centre Beaubourg} in Paris---showing up this quite spectacular phenomenon of the \emph{moiré effect} and the following code was quickly ready made to redesign it within PSTricks.

\begin{center}
\def\myMoire{%
\psset{dimen=inner,linewidth=0pt}
\def\carre{%
\pnodes{AL}(0,0)(-1.5,1.5)(-1.5,1.2)(-1.5,0.9)(-1.5,0.7)(-1.5,0.4)(-1.5,0.2)(-1.5,0)%
(-1.5,-0.2)(-1.5,-0.4)(-1.5,-0.6)(-1.5,-0.75)(-1.5,-0.9)(-1.5,-1.05)(-1.5,-1.15)%
(-1.5,-1.25)(-1.5,-1.3)(-1.5,-1.4)(-1.5,-1.45)
\pnodes{AR}(0,0)(1.5,-1.5)(1.5,-1.2)(1.5,-0.9)(1.5,-0.7)(1.5,-0.4)(1.5,-0.2)(1.5,0)%
(1.5,0.2)(1.5,0.4)(1.5,0.6)(1.5,0.75)(1.5,0.9)(1.5,1.05)(1.5,1.15)(1.5,1.25)%
(1.5,1.3)(1.5,1.4)(1.5,1.45)
\multido{\iA=1+2,\iB=2+2}{9}{\pspolygon*(AL\iA)(AR\iA)(AR\iB)(AL\iB)}%
\pnodes{BL}(0,0)(-1.2,1.5)(-0.9,1.5)(-0.7,1.5)(-0.4,1.5)(-0.2,1.5)(0.0,1.5)(0.2,1.5)%
(0.4,1.5)(0.6,1.5)(0.75,1.5)(0.9,1.5)(1.05,1.5)(1.15,1.5)(1.25,1.5)(1.3,1.5)%
(1.4,1.5)(1.45,1.5)(1.5,1.5)
\pnodes{BR}(0,0)(1.2,-1.5)(0.9,-1.5)(0.7,-1.5)(0.4,-1.5)(0.2,-1.5)(0,-1.5)(-0.2,-1.5)%
(-0.4,-1.5)(-0.6,-1.5)(-0.75,-1.5)(-0.9,-1.5)(-1.05,-1.5)(-1.15,-1.5)(-1.25,-1.5)%
(-1.3,-1.5)(-1.4,-1.5)(-1.45,-1.5)(-1.5,-1.5)
\multido{\iA=1+2,\iB=2+2}{9}{\pspolygon*(BL\iA)(BR\iA)(BR\iB)(BL\iB)}}%
\def\half{%
\rput(0,0){\carre}
\rput(-3,0){\psscalebox{-1 1}{\carre}}
}
\def\pattern{%
\rput(0,0){\half}
\rput(0,-3){\psscalebox{1 -1}{\half}}
}
\multido{\iA=0+6}{2}{\multido{\iB=0+-6}{3}{\rput(\iA,\iB){\pattern}}}}
\psset{unit=0.5}
\begin{animateinline}[controls,loop,
    begin={\begin{pspicture}(-7,-17)(10,3)},
    end={\end{pspicture}}]{10}% 10 frames/s (velocity of the animation)
\multiframe{11}{i=0+2}{% number of frames
\rput(0,0){\myMoire}
\psrotate(1.5,-7){\i}{\myMoire}
}
\multiframe{21}{i=20+-2}{%
\rput(0,0){\myMoire}
\psrotate(1.5,-7){\i}{\myMoire}
}
\multiframe{10}{i=-20+2}{%
\rput(0,0){\myMoire}
\psrotate(1.5,-7){\i}{\myMoire}
}
\end{animateinline}
\end{center}
{\tiny\begin{verbatim}
\def\myMoire{%
\psset{dimen=inner,linewidth=0pt}
\def\carre{%
\pnodes{AL}(0,0)(-1.5,1.5)(-1.5,1.2)(-1.5,0.9)(-1.5,0.7)(-1.5,0.4)(-1.5,0.2)(-1.5,0)%
(-1.5,-0.2)(-1.5,-0.4)(-1.5,-0.6)(-1.5,-0.75)(-1.5,-0.9)(-1.5,-1.05)(-1.5,-1.15)%
(-1.5,-1.25)(-1.5,-1.3)(-1.5,-1.4)(-1.5,-1.45)
\pnodes{AR}(0,0)(1.5,-1.5)(1.5,-1.2)(1.5,-0.9)(1.5,-0.7)(1.5,-0.4)(1.5,-0.2)(1.5,0)%
(1.5,0.2)(1.5,0.4)(1.5,0.6)(1.5,0.75)(1.5,0.9)(1.5,1.05)(1.5,1.15)(1.5,1.25)%
(1.5,1.3)(1.5,1.4)(1.5,1.45)
\multido{\iA=1+2,\iB=2+2}{9}{\pspolygon*(AL\iA)(AR\iA)(AR\iB)(AL\iB)}%
\pnodes{BL}(0,0)(-1.2,1.5)(-0.9,1.5)(-0.7,1.5)(-0.4,1.5)(-0.2,1.5)(0.0,1.5)(0.2,1.5)%
(0.4,1.5)(0.6,1.5)(0.75,1.5)(0.9,1.5)(1.05,1.5)(1.15,1.5)(1.25,1.5)(1.3,1.5)%
(1.4,1.5)(1.45,1.5)(1.5,1.5)
\pnodes{BR}(0,0)(1.2,-1.5)(0.9,-1.5)(0.7,-1.5)(0.4,-1.5)(0.2,-1.5)(0,-1.5)(-0.2,-1.5)%
(-0.4,-1.5)(-0.6,-1.5)(-0.75,-1.5)(-0.9,-1.5)(-1.05,-1.5)(-1.15,-1.5)(-1.25,-1.5)%
(-1.3,-1.5)(-1.4,-1.5)(-1.45,-1.5)(-1.5,-1.5)
\multido{\iA=1+2,\iB=2+2}{9}{\pspolygon*(BL\iA)(BR\iA)(BR\iB)(BL\iB)}}%
\def\half{%
\rput(0,0){\carre}
\rput(-3,0){\psscalebox{-1 1}{\carre}}
}
\def\pattern{%
\rput(0,0){\half}
\rput(0,-3){\psscalebox{1 -1}{\half}}
}
\multido{\iA=0+6}{2}{\multido{\iB=0+-6}{3}{\rput(\iA,\iB){\pattern}}}}

\psset{unit=0.75}
\begin{animateinline}[controls,loop,
    begin={\begin{pspicture}(-7,-19)(10,5)},
    end={\end{pspicture}}]{10}% 10 frames/s (velocity of the animation)
\multiframe{11}{i=0+2}{% number of frames
\rput(0,0){\myMoire}
\psrotate(1.5,-7){\i}{\myMoire}
}
\multiframe{21}{i=20+-2}{%
\rput(0,0){\myMoire}
\psrotate(1.5,-7){\i}{\myMoire}
}
\multiframe{10}{i=-20+2}{%
\rput(0,0){\myMoire}
\psrotate(1.5,-7){\i}{\myMoire}
}
\end{animateinline}
\end{verbatim}}


\newpage


\section{Theory---for the interested user}\label{sec:theory}

\subsection{The contribution of ``\textit{éditions Kangourou}''}

``\textit{Le Kangourou des mathématiques}'': \textcolor{orange}{\url{http://www.mathkang.org/}} published a revue in 2002, ``\textit{Les malices du Kangourou}'' that contains a magnificent article from pages 18 to 26 titled ``\textit{Mirifiques et mirobolants moirés}'' and on the back cover ``\textit{La règle à moirer}'' (``\textit{The ruler}''). The article and the ruler are available at the following addresses:
\begin{center}
\url{http://www.mathkang.org/cite/moires9p.pdf}
\\
\url{http://www.mathkang.org/cite/moirer.html}
\end{center}
The ruler can be purchased at the following address:
\begin{center}
\url{http://www.mathkang.org/catalogue/prodmoir.html}
\end{center}
In the article the sketches are very beautiful and the part ``\textit{Mathématisation du phénomène}'' is remarkable! It contains the following moirés:
\begin{itemize}
  \item a network of parallel straight lines superposed each with a rotation in different direction;
  \item shifted superposition of two networks consisting of radial rays (or rather sectors);
  \item shifted superposition of two frames of Fresnel rings, well known as Newton's rings observed in optics.
\end{itemize}


\newpage


\subsection{The contribution of Henri Bouasse}\label{sec:Bouasse}

\newcounter{boua}
\newcommand{\itemBoua}{\addtocounter{boua}{1}\strut\indent\textit{\theboua}\textsuperscript{o} ---
}

This is the chapter of his book ``\textit{Vision et reproduction des formes et des couleurs}'' published at Librairie Delagrave in Paris in 1917. His demonstration and the diagram within his book have been reproduced here:

\medskip

\psframebox[fillstyle=solid,fillcolor=gray,linestyle=none,framesep=1pt]{\centerline{\white
\Large \textbf{Parallel straight lines}}}

\hrule
\vskip2ex
\itemBoua
Consider two straight lines respectively parallel:
\begin{equation}
x\cos\THETA +y\sin\THETA=bt+ct^2\quad\quad x\cos\THETA -y\sin\THETA=b\TAU-c\TAU^2
\label{eq:droites}
\end{equation}
\begin{figure}[h]
\begin{center}
\begin{pspicture}(-8,-6)(8,6)
\begin{psclip}{\psframe[linestyle=none](-6,-6)(6,6)}
\multido{\i=-10+1}{21}{%
    \parametricplot{-6}{6}{%
        /c 0.1 def
        /b 4.1 def
        /X t def
        /Y X 80 dup sin exch cos div mul
           b \i\space mul c \i\space dup mul mul sub
        sub
        def
        X Y}}
\multido{\i=-10+1}{21}{%
    \parametricplot{-6}{6}{%
        /c 0.1 def
        /b 4.1 def
        /X t def
        /Y X 80 dup sin exch cos div mul neg
           b \i\space mul c \i\space dup mul mul add
        add
        def
        X Y}}
% paraboles
\multido{\i=-4+1}{8}{%
 \parametricplot[linecolor=red]{-6}{6}{%
        /c 0.1 10 sin mul def
        /b 4.1 10 sin mul def
        /X t def
        /Y c X dup mul mul 10 cos dup mul mul
        b c \i\space mul add dup mul 10 sin mul div
        b \i\space mul 2 div 10 sin div
        add
        \i\space dup mul c mul 4 div 10 sin div
        add
        def
        X Y}}
\psline[linestyle=dashed,linecolor=blue](0,6)(0,-6)
\end{psclip}
\rput(-7.5,0){%
    \psline(0,-2)(0,4)
    \psline(-1,0)(1,0)
    \uput[90](0,4){$y$}
    \uput[90](1,0){$x$}
    \psline(4;80)
    \psline(4;100)
    \uput[0](4;80){$\mathrm{S_1}$}
    \uput[180](4;100){$\mathrm{S_2}$}
    \uput[225](0,0){O}
    \psarc(0,0){2}{80}{90}
    \psarc(0,0){1.8}{90}{100}
    \uput[85](2;85){$\THETA$}
    \uput[95](1.8;95){$\THETA$}
    }
\end{pspicture}
\end{center}
\caption{Moiré: parallel lines}
\end{figure}
\indent For $t=\TAU=0$, we get the two lines $\mathrm{OS_2}$ and $\mathrm{OS_1}$; they obviously have the same angle $\THETA$ with the axis $\mathrm{O}y$.

The curves of the intersection points, which correspond to the small diagonals of the parallelograms, satisfy the following condition:
\begin{equation*}
t-\TAU=\MU=\mathrm{constant}
\end{equation*}
\indent Adding and reordering the equations~(\ref{eq:droites}):
\begin{align*}
2x\cos\THETA&=(b+c\MU)(t+\TAU)\\
2y\sin\THETA&=b\MU+c(t^2+\TAU^2)=b\MU+c(\MU^2+2t\TAU)
\end{align*}
\indent To complete the elimination, we will use the following relation:
\begin{equation*}
(t+\TAU)^2-4t\TAU=\MU^2
\end{equation*}
Thus:
\begin{equation}
\frac{4x^2\cos^2\THETA}{(b+c\MU)^2}-\frac{4y\sin\THETA}{c}+\frac{2b\MU}{c}+\MU^2=0\label{parabole}
\end{equation}
\indent The wanted curves are parabolas which have the O$y$ axis in common.

Its vertices are given by:
\begin{equation}
y=\frac{\MU(2b+c\MU)}{4\sin\THETA}
\label{sommets}
\end{equation}

\itemBoua The parameter $c$ is small compared to the parameter $b$, so the equations simplify.

The equation~(\ref{parabole}) becomes:
\begin{equation*}
\frac{4x^2\cos^2\THETA}{b^2}-4y\sin\THETA+2b\MU=0
\end{equation*}

\indent This is the same parabola for all the values of $\MU$ sliding parallely to O$y$. The vertices are given by:
\begin{equation}
y=\MU \frac{b}{2\sin\THETA}
\label{eq:sommets2}
\end{equation}
The radius of curvature at the vertex of the parabola is:
\begin{equation*}
\mathrm{R}=\frac{b^2}{2c}\frac{\sin\THETA}{\cos^2\THETA}
\end{equation*}

\indent If the parallel straight lines are equidistant $(c=0)$, the parabolas degenerate to straight lines~(\ref{eq:sommets2}); in other words, the radius of curvature becomes infinite.
\\
\itemBoua To make an experiment, we trace with ``\textit{China ink}'' on a paper 51 parallel lines with a length of i. e. 20~cm, where the distance between two adjacent lines increases from 2~mm (between the first two lines) to 3~mm (between the last two lines), following the formula:
\begin{equation*}
s=2t+0.01t^2
\end{equation*}

\indent We take a photo by reducing to the half or a quarter. We generate two diapositives\footnote{spelling of the time.}. We realize the phenomenon when placing one over the other by rotating one of them.

We think that if you had followed the given instructions, you might be as well convinced---as we are---it would have been a pity to have left this beautiful demonstration ``\textit{of that time}'' in oblivion!


\subsection{The humble contributions of our group}

These demonstrations contain:
\begin{enumerate}
\item the moirés of Newton. In fact it is a construction similar to that of the Fresnel rings. Here the progression of the squares is such that the areas between two consecutive squares are equal to the area of the central square. One out of every two intervals is made opaque. The resulting moiré figures are equilateral hyperbolas.
\item the moirés obtained by the superposition of Fresnel rings and a network of parallel lines result as well in Fresnel rings.
\end{enumerate}
The source files (\LaTeX) and pdf are found within the repository:
\begin{center}
\url{http://melusine.eu.org/syracuse/G/pstricks/pst-moire/moiredoc/}
\end{center}


\subsection{The construction of a Gauss network}

This method is discussed on page 136 of the book ``\textit{Les phénomènes naturels}'' edited in 1978 by the revue ``\textit{Pour la Science}'' and distributed by the Berlin editions.
\begin{quote}\itshape
<<~The Gauss network is obtained by drawing a series of equidistant vertical lines on a Gaussian curve, then by drawing parallel oblique lines passing through the points of intersection between the vertical lines and the Gaussian curve.~>>
\end{quote}


\subsubsection{Gaussian curve}

\begin{equation*}
y=a\mathrm{e}^{-(kx)^2}
\end{equation*}
\begin{center}
\begin{pspicture}(-6,-0.5)(6,3.5)
\psparametricplot[plotpoints=1000]{-6}{6}{%
                  t
                  3 2.71828 -0.5 t dup mul mul exp mul
                  }
\end{pspicture}
\end{center}


\subsubsection{Determination of the points of intersection}\label{sec:Gauss}

The equidistant vertical line network has for equation: $x=ne$, $e$ is the spacing and $n$ is an integer.

The ordinates of the intersection points are: $y_n=a\mathrm{e}^{-(kne)^2}$. Within the following figure, we set the spacing between the points on the Gaussian curve with the key \texttt{E=0.5} (in cm).
\begin{center}
\begin{pspicture}(-6,-0.5)(6,3.5)
\parametricplot[plotpoints=1000]{-6}{6}{%
                  t
                  3 2.71828 0.5 t mul dup mul neg exp mul
                  }
\pstVerb{/A1 3 def
         /K1 0.5 def
         /E1 0.5 def
         /Alpha 70 def
         /m1 {Alpha dup sin exch cos div} bind def
}%
\multido{\n=-12+1}{25}{%
%\pstVerb{/B1 {A1 2.71828 K \n\space mul E1 mul dup mul neg exp \n\space E mul m1 mul sub} def}%
 \psdot(! \n\space E1 mul % x
         A1 2.71828 K1 \n\space E1 mul mul dup mul neg exp mul)
  }
\psline[linecolor=red]{|<->|}(! -11 E1 mul 0.5)(! -10 E1 mul 0.5)
\uput[90](! -10.5 E1 mul 0.5){\textcolor{red}{\texttt{E=0.5}}}
\psline[linecolor=red]{|<->|}(! -5 E1 mul 1.5)(! -4 E1 mul 1.5)
\uput[90](! -4.5 E1 mul 1.5){\textcolor{red}{\texttt{E=0.5}}}
\psline[linecolor=red]{|<->|}(! 5 E1 mul 1)(! 6 E1 mul 1)
\uput[90](! 5.5 E1 mul 1){\textcolor{red}{\texttt{E=0.5}}}
\end{pspicture}
\end{center}


\subsubsection{Drawing the network of the straight lines}

We determine the equations of the straight lines passing through these points and which are inclined by an angle $\alpha$ with respect to the horizontal. This is to setup with the key \texttt{Alpha=} (in degrees).

The general equation of such a line is given by: $y=x\tan(\alpha)+b$, we determine $b$ to go through one of the previous points.
\begin{equation*}
ne\tan(\alpha)+b=a\mathrm{e}^{-(kne)^2}
\end{equation*}
so we get $b$.
\begin{equation*}
b=a\mathrm{e}^{-(kne)^2}-ne\tan(\alpha)
\end{equation*}


\newpage


For every value of $n$ we get a straight line.
\begin{equation*}
y=x\tan(\alpha)+a\mathrm{e}^{-(kne)^2}-ne\tan(\alpha)
\end{equation*}
Let's draw some of these straight lines. Setting $a=3$, $k=0.5$, $-20<n<+20$, $e=0.5$ and $\alpha=70^{\mathrm{o}}$

\begin{center}
\begin{pspicture*}(-6,-1)(6,10)
\parametricplot[plotpoints=1000,linecolor=red]{-6}{6}{%
                  t
                  3 2.71828 0.5 t mul dup mul neg exp mul}
\pstVerb{/A1 3 def
         /K1 0.5 def
         /E1 0.5 def
         /Alpha 70 def
         /m1 {Alpha dup sin exch cos div} bind def % pente de la droite
}%
\multido{\n=-20+1}{41}{%
\pnode(! \n\space E1 mul % x
         A1 2.71828 K1 \n\space E1 mul mul dup mul neg exp mul){A}
 \psdot(A)
\rput(A){\psline(! -4 -4 m1 mul)(! 4 4 m1 mul)}
  }
\end{pspicture*}
\end{center}
\begin{verbatim}
\begin{pspicture*}(-6,-1)(6,10)
\parametricplot[plotpoints=1000,linecolor=red]{-6}{6}{%
                  t
                  3 2.71828 0.5 t mul dup mul neg exp mul}
\pstVerb{/A 3 def
         /K 0.5 def
         /E 0.5 def
         /Alpha 70 def
         /m {Alpha dup sin exch cos div} bind def % pente de la droite
}%
\multido{\n=-20+1}{41}{%
\pnode(! \n\space E mul % x
         A 2.71828 K \n\space E mul mul dup mul neg exp mul){A}
 \psdot(A)
\rput(A){\psline(! -4 -4 m mul)(! 4 4 m mul)}
  }
\end{pspicture*}
\end{verbatim}
The last step is to translate these lines into PostScript code.


\subsection{Some moiré figures}

\subsubsection{\texttt{type=circle + type=circle}}

\begin{center}
\psscalebox{0.6}{%
\begin{pspicture*}(-6,-6)(6,6)
\psset{dimen=middle}
\multido{\rA=0.5+0.5}{11}{%
\pscircle(-2,0){!\rA\space}
\pscircle(2,0){!\rA\space}
}%
\end{pspicture*}
}
\hfill
\psscalebox{0.6}{%
\begin{pspicture*}(-6,-6)(6,6)
\psset{linecolor={[cmyk]{0.5 0 0 0.5}},dimen=middle}
\multido{\rA=0.5+0.5}{11}{%
\pscircle(-2,0){!\rA\space}
\pscircle(2,0){!\rA\space}
}%
\pstVerb{/C1 2 def
         /K1 0.5 def}%
\multido{\iH=-7+1,\iE=9+1}{15}{%
\pstVerb{/A1 K1 \iH\space mul 2 div def
         /B1 C1 dup mul A1 dup mul sub sqrt def}%
\parametricplot[linecolor=red]{-2}{2}{%
    A1 t COSH mul
    B1 t SINH mul}
\pstVerb{/A1 K1 \iE\space mul 2 div def
         /B1 A1 dup mul C1 dup mul sub sqrt def}
\parametricplot[linecolor=gray,linestyle=dashed]{0}{360}{%
    A1 t sin mul
    B1 t cos mul}}
\end{pspicture*}
}
\end{center}
\textbf{Mathematization}

Equidistant radii that increase like: $r_n=n\cdot a$, with $a>0$.

We have
\begin{align*}
(x-c)^2+y^2&=k^2p^2\\
(x+c)^2+y^2&=k^2q^2
\end{align*}
It is necessarily: $p-q=m\in\mathbb{Z}$, thus
\begin{align*}
p&=\frac{1}{k}\sqrt{(x-c)^2+y^2}\\
q&=\frac{1}{k}\sqrt{(x+c)^2+y^2}
\end{align*}
and $p-q=m$
\begin{gather*}
\sqrt{(x-c)^2+y^2}-\sqrt{(x+c)^2+y^2}= k m\\
r_p=p\cdot k\qquad r_q=q\cdot k\\
r_p-r_q=(p-q)\cdot k=m\cdot k
\end{gather*}
The points of the moiré curves are such that the difference in distances to the two centers is constant. The moiré curves are hyperbolas focussing the centers of circles.

We pose: $a=\frac{km}{2}$ and $b^2=c^2-a^2$. The equations of this family of hyperbolas are written like:
\begin{align*}
x&=a\cosh(t)\\
y&=b\sinh(t)
\end{align*}
or:
\begin{align*}
x&=\frac{a}{\cos(t)}\\
y&=b\tan(t)
\end{align*}
If we go from a point of intersection $(p,q)$ to a point $(p+1,q-1)$, the sum of the distances remains constant. As a result, we say:
\begin{equation*}
r_p+r_q=(p+q)\cdot k=n\cdot k
\end{equation*}
This family of moiré curves are ellipses with equations like:
\begin{equation*}
x=a\cos(t)\quad y=b\sin(t)
\end{equation*}
with:
\[
b^2=a^2-c^2
\]


\subsubsection{\texttt{type=square + type=Fresnel}}

\begin{center}
\psscalebox{0.6}{%
\begin{pspicture}(-6,-6)(6,6)
\psmoire[type=square]
\psmoire[type=Fresnel]
\end{pspicture}
}
\hfill
\psscalebox{0.6}{%
\begin{pspicture}(-6,-6)(6,6)
\psset{linecolor={[cmyk]{0.5 0 0 0.5}},dimen=middle}
\multido{\rA=1+1}{22}{%
\pscircle{!\rA\space sqrt}
}%
\multido{\ri=0.25+0.25}{18}{%
\psline(!\ri\space 5.8 neg)(!\ri\space 5.8)
}%
\multido{\iA=0+-1}{4}{%
\pscircle[linecolor=red](2,0){!4 \iA\space add sqrt}
}
\end{pspicture}
}
\end{center}

\textbf{Mathematization}

The abscissa of the edges of the square with $x>0$ increase with: $x_n=a\cdot n$, with $a>0$

The radii increase with: $r_n=\sqrt{n}$.

We have
\begin{align*}
x&=ap\\
x^2+y^2&=q
\end{align*}
\begin{align*}
p&=\frac{x}{a}\\
q&=x^2+y^2
\end{align*}
On a curve of moiré, we verify: $p-q=m\in\mathbb{Z}$:
\begin{equation*}
\left(x-\frac{1}{2a}\right)^2+y^2=m+\frac{1}{4a^2}
\end{equation*}
This family of moiré curves are circles with the center at $(\frac{1}{2a},0)$ and with a radius of $r_m=\sqrt{m+\frac{1}{4a^2}}$


\subsubsection{\texttt{type=circle + type=Newton}}

\begin{center}
%\psset{scale=0.5,Rmax=7.5}
\psscalebox{0.6}{%
\begin{pspicture}(-6,-6)(6,6)
\psmoire[type=circle]
\psmoire[type=Newton]
\end{pspicture}
}
\hfill
\psscalebox{0.6}{%
\begin{pspicture}(-6,-6)(6,6)
\psset{linecolor={[cmyk]{0.5 0 0 0.5}},dimen=middle}
\multido{\rA=0.25+0.25}{22}{%
\pscircle{!\rA\space}
}%
\multido{\i=1+1}{33}{%
\psline(!\i\space sqrt 5.8 neg)(!\i\space sqrt 5.8)
}%
\psplotImp[algebraic,linecolor=red](1,-5)(5.8,5){x^2-4*sqrt(x^2+y^2)+7}
\psplotImp[algebraic,linecolor=red](1,-5)(5.8,5){x^2-4*sqrt(x^2+y^2)+6}
\psplotImp[algebraic,linecolor=red](1,-5)(5.8,5){x^2-4*sqrt(x^2+y^2)+5}
\psplotImp[algebraic,linecolor=red](1,-5)(5.8,5){x^2-4*sqrt(x^2+y^2)+4}
\psplotImp[algebraic,linecolor=red](1,-5)(5.8,5){x^2-4*sqrt(x^2+y^2)+3}
\psplotImp[algebraic,linecolor=red](1,-5)(5.8,5){x^2-4*sqrt(x^2+y^2)+2}
\psplotImp[algebraic,linecolor=red](1,-5)(5.8,5){x^2-4*sqrt(x^2+y^2)+1}
\psplotImp[algebraic,linecolor=red](1,-5)(5.8,5){x^2-4*sqrt(x^2+y^2)+0}
\end{pspicture}
}
\end{center}

\textbf{Mathematization}

The abscissa of the edges of the square with $x>0$ increase with: $x_n=\sqrt{n}$.

The radii increase with: $r_n=n\cdot a$, with $a>0$.

\begin{minipage}[t]{0.3\linewidth}\kern0pt
We have:
\begin{align*}
x&=\sqrt{p}\\
x^2+y^2&=a^2q^2
\end{align*}
It is necessarily: $p-q=m\in\mathbb{Z}$, thus
\begin{align*}
p&=x^2\\
q&=\frac{1}{a}\sqrt{x^2+y^2}
\end{align*}
and $p-q=m$
\begin{equation*}
x^2-\frac{1}{a}\sqrt{x^2+y^2}=m
\end{equation*}
In polar coordinates:
\begin{gather*}
\rho^2(\cos\theta)^2-\frac{\rho}{a}-m=0\\
\Delta=\left(\frac{-1}{a}\right)^2+4m(\cos\theta)^2\\
\rho=\frac{\frac{1}{a}\pm\sqrt{\Delta}}{2(\cos\theta)^2}
\end{gather*}
\end{minipage}
\hfill
\begin{minipage}[t]{0.65\linewidth}\kern0pt
\psscalebox{0.7}{%
\begin{pspicture*}(-6,-6)(6,6)
\psset{linecolor={[cmyk]{0.5 0 0 0.5}},dimen=middle}
\multido{\rA=0.25+0.25}{30}{%
\pscircle{!\rA\space}
}%
\multido{\i=1+1}{40}{%
\psline(!\i\space sqrt 6 neg)(!\i\space sqrt 6)
}%
\pstVerb{/A1 0.25 def % 1/0.25
         /A_1 1 A1 div def
         /Delta {A_1 dup mul 4 m neg mul x cos dup mul mul sub sqrt} def}%
\multido{\im=5+-1}{10}{%
\pstVerb{/m \im\space def}%
\psplot[polarplot=true,plotpoints=361,linecolor=red]{-89}{89}{%
          A_1 neg Delta add x cos dup mul 2 mul div neg }
\psplot[polarplot=true,plotpoints=361,linecolor=red]{-89}{89}{%
          A_1 neg Delta sub x cos dup mul 2 mul div abs }%
}
\end{pspicture*}
}
\end{minipage}


\subsubsection{\texttt{type=circle + type=Fresnel}}

\begin{center}
%\psset{scale=0.5}
\psscalebox{0.6}{%
\begin{pspicture}(-6,-6)(6,6)
\psmoire[type=Fresnel](0.2,0)
\psmoire[type=circle](-0.2,0)
\end{pspicture}
}
\hfill
\psscalebox{0.6}{%
\begin{pspicture}(-6,-6)(6,6)
\psset{linecolor={[cmyk]{0.5 0 0 0.5}}}
\multido{\rA=0.25+0.25}{22}{%
\pscircle(-0.2,0){!\rA\space}
}%
\multido{\iA=1+1}{31}{%
\pscircle(0.2,0){!\iA\space sqrt}
}%
\psset{linewidth=1.5\pslinewidth}
\psplotImp[algebraic,linecolor=red](-5.8,-5)(5.8,5){(x-0.2)^2+y^2-4*sqrt((x+0.2)^2+y^2)+1}
\psplotImp[algebraic,linecolor=red](-5.8,-5)(5.8,5){(x-0.2)^2+y^2-4*sqrt((x+0.2)^2+y^2)+2}
\psplotImp[algebraic,linecolor=red](-5.8,-5)(5.8,5){(x-0.2)^2+y^2-4*sqrt((x+0.2)^2+y^2)+3}
\psplotImp[algebraic,linecolor=red](-5.8,-5)(5.8,5){(x-0.2)^2+y^2-4*sqrt((x+0.2)^2+y^2)+4}
\psplotImp[algebraic,linecolor=red](-5.8,-5)(5.8,5){(x-0.2)^2+y^2-4*sqrt((x+0.2)^2+y^2)+5}
\end{pspicture}
}
\end{center}

\textbf{Mathematization}

The radii of the Fresnel circles increase: $r_n=\sqrt{n}$.

The radii of the equidistant circles increase: $r_n=n\cdot a$, with $a>0$.

The centers of the circles are placed at $(x_M,0)$ and $(-x_M,0)$, we have $p$ and $q$ as integers:
\begin{align*}
(x-x_M)^2+y^2&=p\\
(x+x_M)^2+y^2&=a^2q^2\\
p&=(x-x_M)^2+y^2\\
q&=\frac{1}{a}\sqrt{(x+x_M)^2+y^2}
\end{align*}
One moiré curve line is determined by:  $p-q=m\in\mathbb{Z}$, thus:
\begin{equation*}
(x-x_M)^2+y^2-\frac{1}{a}\sqrt{(x+x_M)^2+y^2}=m
\end{equation*}
which is the implicit equation of a moiré curve line with $m$.


\subsubsection{Circles and Squares (both of increasing thickness)}

\begin{center}
\psscalebox{0.6}{%
\def\epaisseur{0.0075}
\begin{pspicture}(-6,-6)(6,6)
\psset{dimen=middle}
\pstVerb{/Radius 0.25 def}%
\multido{\i=1+1}{41}{%
\FPeval\epaisseur{1.08*(\epaisseur)}
\psset{linewidth=\epaisseur}
\pscircle{!Radius}
\pstVerb{/Radius Radius 1.08 mul def}%
}%
\pstVerb{/Radius 0.25 def}%
\multido{\i=1+1}{33}{%
\FPeval\epaisseur{1.1*(\epaisseur)}
\psset{linewidth=\epaisseur}
\psframe(!Radius neg Radius neg)(!Radius Radius)
\pstVerb{/Radius Radius 1.1 mul def}%
}%
\end{pspicture}
}
\hfill
\psscalebox{0.6}{%
\begin{pspicture}(-6,-6)(6,6)
\psset{linecolor={[cmyk]{0.5 0 0 0.5}},dimen=middle}
\pstVerb{/Radius 0.25 def}%
\multido{\i=1+1}{41}{%
\pscircle{!Radius}
\pstVerb{/Radius Radius 1.08 mul def}%
}%
\pstVerb{/Radius 0.25 def}%
\multido{\i=1+1}{33}{%
\psline(!Radius 5.8 neg)(!Radius 5.8)
\pstVerb{/Radius Radius 1.1 mul def}%
}%
\psplotImp[algebraic,linecolor=red](0,-6)(5,6){((4*x)^(1/ln(1.1)))/((16*(x^2+y^2))^(1/ln((1.08)^2)))-Euler^(-6)}
\psplotImp[algebraic,linecolor=red](0,-6)(5,6){((4*x)^(1/ln(1.1)))/((16*(x^2+y^2))^(1/ln((1.08)^2)))-Euler^(-5)}
\psplotImp[algebraic,linecolor=red](0,-6)(5,6){((4*x)^(1/ln(1.1)))/((16*(x^2+y^2))^(1/ln((1.08)^2)))-Euler^(-4)}
\end{pspicture}
}
\end{center}

\textbf{Mathematization}

The abscissa of the edges of the square with $x>0$ increase with: $x_n=\frac{1}{4}a^n$, with $a>1$.

The radii increase with: $r_n=\frac{1}{4}b^n$, with $b>1$.

We have
\begin{align*}
x_p&=\frac{1}{4}a^p\\
r_q^2&=x^2+y^2\\
x^2+y^2&=\frac{1}{16}b^{2q}
\end{align*}
If we consider the point determined by the intersection $p\cap q$, the next point will be $(p+1)\cap (q+1)$, the next one at $(p+2)\cap (q+2)$, etc., so that the difference between the indices remains constant. As a result, the moiré lines are characterized by the relation $p-q=m \in \mathbb{Z}$, $m$ determines a moiré curve.
\begin{align*}
p&=\frac{\ln(4x)}{\ln a}\\
q&=\frac{\ln[16(x^2+y^2)]}{2\ln b}
\end{align*}
and $p-q=m$
\begin{equation*}
\ln(4x)^{\frac{1}{\ln a}}-\ln[16(x^2+y^2)]^{\frac{1}{2\ln b}}=m
\end{equation*}
finally gives
\begin{equation*}
\frac{(4x)^{\frac{1}{\ln a}}}{[16(x^2+y^2)]^{\frac{1}{2\ln b}}}=\text{e}^m
\end{equation*}
We transform this implicit equation into a polar equation by setting $\rho^2=x^2+y^2$ and $x=\rho\cos\theta$.
%Remarquons que pour le point $(x=0,y=0)$ correspond à $\theta=\pi/2$.

Setting $\alpha=\frac{1}{\ln a}$ and $\beta=\frac{1}{2\ln b}$. The equation becomes:
\begin{gather*}
\frac{\rho^\alpha(\cos\theta)^\alpha\cdot 4^{\alpha}}{\rho^{2\beta}\cdot 4^{2\beta}}=\text{e}^m\\
\rho^{\alpha-2\beta}(\cos\theta)^\alpha=\text{e}^m\cdot 4^{2\beta-\alpha}\\
\rho=\frac{1}{4}\left(\frac{\mathrm{e}^m}{(\cos\theta)^{\alpha}}\right)^{\frac{1}{\alpha-2\beta}}
\end{gather*}
We can trace some elements of this family of curves:\label{sec:theoryEnd}
\begin{center}
\psscalebox{0.6}{%
\begin{pspicture*}(-6,-6)(6,6)
\psset{linecolor={[cmyk]{0.5 0 0 0.5}},dimen=middle}
\pstVerb{/Radius 0.25 def}%
\multido{\i=1+1}{41}{%
\pscircle{!Radius}
\pstVerb{/Radius Radius 1.08 mul def}%
}%
\pstVerb{/Radius 0.25 def}%
\multido{\i=1+1}{33}{%
\psline(!Radius 5.8 neg)(!Radius 5.8)
\pstVerb{/Radius Radius 1.1 mul def}%
}%
\pstVerb{/alpha 1 1.1 ln div def
         /beta 1 1.08 ln 2 mul div def
         /a_b 1 alpha 2 beta mul sub div def
         /A {2.718 m exp a_b exp 0.25 mul} def }%
\multido{\im=-14+1}{14}{%
\pstVerb{/m \im\space def}%
\psplot[polarplot=true,plotpoints=361,linecolor=red]{-89}{89}{%
          A x cos alpha neg a_b mul exp mul}%
}
\end{pspicture*}
}
\end{center}


\newpage


\section{List of all optional arguments for \texttt{pst-moire}}

\xkvview{family=pst-moire,columns={key,type,default}}

\clearpage

\nocite{*}
\bgroup
\RaggedRight
\printbibliography
\egroup

\printindex


\newpage


\begin{appendix}
\section{PostScript Font Names}\label{sec:PSF}

\begin{minipage}[t]{0.45\linewidth}\kern0pt
\subsubsection*{Ghostscript}

\begin{tabular}{ll}
uagd8a    & URWGothicL-Demi           \\
uagdo8a   & URWGothicL-DemiObli       \\
uagk8a    & URWGothicL-Book           \\
uagko8a   & URWGothicL-BookObli       \\
ubkd8a    & URWBookmanL-DemiBold      \\
ubkdi8a   & URWBookmanL-DemiBoldItal  \\
ubkl8a    & URWBookmanL-Ligh          \\
ubkli8a   & URWBookmanL-LighItal      \\
ucrb8a    & NimbusMonL-Bold           \\
ucrbo8a   & NimbusMonL-BoldObli       \\
ucrr8a    & NimbusMonL-Regu           \\
ucrro8a   & NimbusMonL-ReguObli       \\
uhvb8a    & NimbusSanL-Bold           \\
uhvb8ac   & NimbusSanL-BoldCond       \\
uhvbo8a   & NimbusSanL-BoldItal       \\
uhvbo8ac  & NimbusSanL-BoldCondItal   \\
uhvr8a    & NimbusSanL-Regu           \\
uhvr8ac   & NimbusSanL-ReguCond       \\
uhvro8a   & NimbusSanL-ReguItal       \\
uhvro8ac  & NimbusSanL-ReguCondItal   \\
uncb8a    & CenturySchL-Bold          \\
uncbi8a   & CenturySchL-BoldItal      \\
uncr8a    & CenturySchL-Roma          \\
uncri8a   & CenturySchL-Ital          \\
uplb8a    & URWPalladioL-Bold         \\
uplbi8a   & URWPalladioL-BoldItal     \\
uplr8a    & URWPalladioL-Roma         \\
uplri8a   & URWPalladioL-Ital         \\
usyr      & StandardSymL              \\
utmb8a    & NimbusRomNo9L-Medi        \\
utmbi8a   & NimbusRomNo9L-MediItal    \\
utmr8a    & NimbusRomNo9L-Regu        \\
utmri8a   & NimbusRomNo9L-ReguItal    \\
uzcmi8a   & URWChanceryL-MediItal     \\
uzdr      & Dingbats
\end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\linewidth}\kern0pt
\subsubsection*{Adobe Basic 14}

\begin{tabular}{ll}
Times        & Times-Roman            \\
             & Times-Italic           \\
             & Times-Bold             \\
             & Times-BoldItalic       \\
Helvetica    & Helvetica              \\
             & Helvetica-Oblique      \\
             & Helvetica-Bold         \\
             & Helvetica-BoldOblique  \\
Courier      & Courier                \\
             & Courier-Oblique        \\
             & Courier-Bold           \\
             & Courier-BoldOblique    \\
ZapfDingbats & ZapfDingbats           \\
Symbol       & Symbol
\end{tabular}
\end{minipage}
\end{appendix}
\end{document} 