\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[a4paper]{geometry}
\usepackage{pst-thick}
\usepackage{pst-slpe,pst-grad,pst-text}
\usepackage{url}
\usepackage{array,booktabs}
\usepackage{graphicx}
\usepackage{frenchle}
\input{random}
% RANDOM.TEX       v.1   (Donald Arseneau)
% Generating "random" numbers in TeX

\newpsstyle{vide}{linestyle=none}
\newpsstyle{onlythecurveblue}{linecolor=blue,plotpoints=360}
\newpsstyle{onlythecurvegreen}{linecolor=green,plotpoints=360}
\newpsstyle{onlythecurveyellow}{linecolor=yellow,plotpoints=360}
\newpsstyle{thicklinebleu}{fillstyle=solid,fillcolor=blue!50,linecolor=blue,plotpoints=360}
\newpsstyle{thicklinejaune}{fillstyle=solid,fillcolor=yellow!50,linecolor=yellow,plotpoints=360}
\newpsstyle{thicklinevert}{fillstyle=solid,fillcolor=green!50,linecolor=green,plotpoints=360}
\newpsstyle{thicklinerouge}{fillstyle=solid,fillcolor=red!50,linecolor=red,plotpoints=360}

\date{26 août 2\,007}
\author{Manuel \textsc{Luque}\\
 \texttt{\footnotesize manuel.luque27@gmail.com}}
\title{%
\begin{center}
\psset{unit=0.5}
\begin{pspicture}(0,-0.5)(20,1.5)
\psthick[E=1.2,stylethick=default,plotpoints=720]{1}{19}{\fonctionSinus{10}{1}}%
\rput(0,0){\pstextpath[c]{\parametricplot[linestyle=none]{1}{19}{%
    /P 10 def % période (10 unités)
    /A 1 def % amplitude
    /O 360 P div def
     t O t mul sin A mul
    }}{\textcolor{red}{ Exemples du package \texttt{pst-ticks}-2 }}}
\end{pspicture}
\end{center}}

\def\fonctionCercle#1#2#3{% {x_centre}{y_centre}{rayon}
    /xC #1 def %
    /yC #2 def %
    /radius #3 def
    /x0 t cos radius mul xC add def
    /y0 t sin radius mul yC add def
    /dx t dt add cos radius mul xC add
        x0 sub def
     /dy t dt add sin radius mul yC add
         y0 sub def}

\begin{document}
\maketitle

\section{Les anneaux olympiques}
\begin{center}
\begin{pspicture}(-7.3,-5)(7.3,2.5)
\psframe(-7.3,-5)(7.3,2.5)
\psthick[E=0.5,linestyle=none,stylethick=thicklinebleu]{0}{360}{\fonctionCercle{-4.8}{0}{2}}%
\psthick[E=0.5,curveonly,stylecurve1=onlythecurveblue,stylecurve2=onlythecurveblue]{0}{360}{\fonctionCercle{-4.8}{0}{2}}%
\psthick[E=0.5,linestyle=none,stylethick=thicklinejaune]{0}{360}{\fonctionCercle{-2.4}{-2.4}{2}}%
\psthick[E=0.5,curveonly,stylecurve1=onlythecurveyellow,stylecurve2=onlythecurveyellow]{0}{360}{\fonctionCercle{-2.4}{-2.4}{2}}%
\psthick[E=0.5,stylethick=solide]{0}{360}{\fonctionCercle{0}{0}{2}}%
\psthick[E=0.5,linestyle=none,stylethick=thicklinevert]{0}{360}{\fonctionCercle{2.4}{-2.4}{2}}%
\psthick[E=0.5,curveonly,stylecurve1=onlythecurvegreen,stylecurve2=onlythecurvegreen]{0}{360}{\fonctionCercle{2.4}{-2.4}{2}}%
\psthick[E=0.5,linestyle=none,stylethick=thicklinerouge]{0}{360}{\fonctionCercle{4.8}{0}{2}}%
\psthick[E=0.5,curveonly,stylecurve1=onlythecurvered,stylecurve2=onlythecurvered]{0}{360}{\fonctionCercle{4.8}{0}{2}}%
\psclip{\psthick[E=0.6,stylethick=vide]{0}{360}{\fonctionCercle{-2.4}{-2.4}{2}}} % jaune
\psthick[E=0.5,stylethick=thicklinebleu]{320}{360}{\fonctionCercle{-4.8}{0}{2}}% bleu
\endpsclip%
\psclip{\psthick[E=0.6,stylethick=vide]{180}{225}{\fonctionCercle{0}{0}{2}}} % noir
\psthick[E=0.5,stylethick=thicklinejaune]{0}{360}{\fonctionCercle{-2.4}{-2.4}{2}}%% jaune
\endpsclip%
\psclip{\psthick[E=0.6,stylethick=vide]{90}{135}{\fonctionCercle{2.4}{-2.4}{2}}} % vert
\psthick[E=0.5,stylethick=solide]{0}{360}{\fonctionCercle{0}{0}{2}}%% noir
\endpsclip%
\psclip{\psthick[E=0.6,stylethick=vide]{180}{225}{\fonctionCercle{4.8}{0}{2}}} % rouge
\psthick[E=0.5,stylethick=thicklinevert]{0}{360}{\fonctionCercle{2.4}{-2.4}{2}}% vert
\endpsclip%
\end{pspicture}
\end{center}

\begin{center}
\psset{unit=0.5}
\begin{pspicture}(-11,-5)(11,2.5)
\psframe(-11,-5)(11,2.5)
\psthick[E=0.5,linestyle=none,stylethick=thicklinebleu]{0}{360}{\fonctionCercle{-4.8}{0}{2}}%
\psthick[E=0.5,curveonly,stylecurve1=onlythecurveblue,stylecurve2=onlythecurveblue]{0}{360}{\fonctionCercle{-4.8}{0}{2}}%
\psthick[E=0.5,linestyle=none,stylethick=thicklinejaune]{0}{360}{\fonctionCercle{-2.4}{-2.4}{2}}%
\psthick[E=0.5,curveonly,stylecurve1=onlythecurveyellow,stylecurve2=onlythecurveyellow]{0}{360}{\fonctionCercle{-2.4}{-2.4}{2}}%
\psthick[E=0.5,stylethick=solide]{0}{360}{\fonctionCercle{0}{0}{2}}%
\psthick[E=0.5,linestyle=none,stylethick=thicklinevert]{0}{360}{\fonctionCercle{2.4}{-2.4}{2}}%
\psthick[E=0.5,curveonly,stylecurve1=onlythecurvegreen,stylecurve2=onlythecurvegreen]{0}{360}{\fonctionCercle{2.4}{-2.4}{2}}%
\psthick[E=0.5,linestyle=none,stylethick=thicklinerouge]{0}{360}{\fonctionCercle{4.8}{0}{2}}%
\psthick[E=0.5,curveonly,stylecurve1=onlythecurvered,stylecurve2=onlythecurvered]{0}{360}{\fonctionCercle{4.8}{0}{2}}%
\psclip{\psthick[E=0.6,stylethick=vide]{0}{360}{\fonctionCercle{-2.4}{-2.4}{2}}} % jaune
\psthick[E=0.5,stylethick=thicklinebleu]{320}{360}{\fonctionCercle{-4.8}{0}{2}}% bleu
\endpsclip%
\psclip{\psthick[E=0.6,stylethick=vide]{180}{225}{\fonctionCercle{0}{0}{2}}} % noir
\psthick[E=0.5,stylethick=thicklinejaune]{0}{360}{\fonctionCercle{-2.4}{-2.4}{2}}%% jaune
\endpsclip%
\psclip{\psthick[E=0.6,stylethick=vide]{90}{135}{\fonctionCercle{2.4}{-2.4}{2}}} % vert
\psthick[E=0.5,stylethick=solide]{0}{360}{\fonctionCercle{0}{0}{2}}%% noir
\endpsclip%
\psclip{\psthick[E=0.6,stylethick=vide]{180}{225}{\fonctionCercle{4.8}{0}{2}}} % rouge
\psthick[E=0.5,stylethick=thicklinevert]{0}{360}{\fonctionCercle{2.4}{-2.4}{2}}% vert
\endpsclip%
\rput(-9,-1.3){\psscaleboxto(4,7){N}}
\rput(9,-1.3){\psscaleboxto(4,7){N}}
%\psgrid
\end{pspicture}
\end{center}
\section{Courbes de Bezier}
\def\BEZIER(#1,#2)(#3,#4)(#5,#6)(#7,#8){%
    /B0 1 t sub 3 exp def % B0=(1-t)^3
    /B1 3 t mul 1 t sub dup mul mul def % B1=3*t*(1-t)^2
    /B2 3 t dup mul mul 1 t sub mul def % B2=3*t^2*(1-t)
    /B3 t 3 exp def                     % B3=t^3
    %
    /B01 1 t dt add sub 3 exp def
    /B11 3 t dt add mul 1 t dt add sub dup mul mul def
    /B21 3 t dt add dup mul mul 1 t dt add sub mul def
    /B31 t dt add 3 exp def
    % x=B0*x0+B1*x1+B2*x2+b3*x3
    /x0 B0 #1 mul B1 #3 mul add B2 #5 mul add B3 #7 mul add def
    % y=B0*y0+B1*y1+B2*y2+b3*y3
    /y0 B0 #2 mul B1 #4 mul add B2 #6 mul add B3 #8 mul add def
    %
    /x01 B01 #1 mul B11 #3 mul add B21 #5 mul add B31 #7 mul add def
    /y01 B01 #2 mul B11 #4 mul add B21 #6 mul add B31 #8 mul add def
    /dx x01 x0 sub def
    /dy y01 y0 sub def
}
{\psset{unit=0.75}
\begin{pspicture}(-5,-7)(3,7)
\psthick[E=1,stylethick=thicklinebleu,linewidth=0.2]{0}{1}{\BEZIER(-5,0)(-3,7)(3,3)(-2,-5)}%
\psline(-5,0)(-3,7)(3,3)(-2,-5)\psdots[linecolor=red](-5,0)(-3,7)(3,3)(-2,-5)
\psbezier[linestyle=dashed](-5,0)(-3,7)(3,3)(-2,-5)%
\psgrid[subgriddiv=0](-5,-6)(3,7)
\end{pspicture}
\hfill
\begin{pspicture}(0,-1)(10,13)
\psthick[E=1,linewidth=0.2]{0}{1}{\BEZIER(0,0)(1.5,10)(8,2)(10,10)}%
\psline(0,0)(1.5,10)(8,2)(10,10)\psdots[linecolor=blue](0,0)(1.5,10)(8,2)(10,10)
\psbezier[linestyle=dashed](0,0)(1.5,10)(8,2)(10,10)
\multido{\n=0+0.05}{21}{%
\pstVerb{/t \n\space def
    /E 1 def
    /K 0 def
    /dt 0.01 def
    \BEZIER(0,0)(1.5,10)(8,2)(10,10)
    /ds dx dup mul dy dup mul add sqrt def
    /dx dx ds div def
    /dy dy ds div def
    /dx' K cos dx mul K sin dy mul sub def
    /dy' K sin dx mul K cos dy mul add def
    /nx E 2 div dy' mul neg def % normale x
    /ny E 2 div dx' mul def % normale y
    /x1 x0 nx add def
    /y1 y0 ny add def}
\pnode(!x1 y1){A}
\pnode(!
    /x2 x0 nx sub def
    /y2 y0 ny sub def
      x2 y2){B}
\psdot[linecolor=blue](A)
\psdot[linecolor=blue](B)
\psline(A)(B)}
\psgrid[subgriddiv=0](10,13)
\end{pspicture}}
{\small
\begin{verbatim}
def\BEZIER(#1,#2)(#3,#4)(#5,#6)(#7,#8){%
    /B0 1 t sub 3 exp def % B0=(1-t)^3
    /B1 3 t mul 1 t sub dup mul mul def % B1=3*t*(1-t)^2
    /B2 3 t dup mul mul 1 t sub mul def % B2=3*t^2*(1-t)
    /B3 t 3 exp def                     % B3=t^3
    %
    /B01 1 t dt add sub 3 exp def
    /B11 3 t dt add mul 1 t dt add sub dup mul mul def
    /B21 3 t dt add dup mul mul 1 t dt add sub mul def
    /B31 t dt add 3 exp def
    % x=B0*x0+B1*x1+B2*x2+B3*x3
    /x0 B0 #1 mul B1 #3 mul add B2 #5 mul add B3 #7 mul add def
    % y=B0*y0+B1*y1+B2*y2+B3*y3
    /y0 B0 #2 mul B1 #4 mul add B2 #6 mul add B3 #8 mul add def
    %
    /x01 B01 #1 mul B11 #3 mul add B21 #5 mul add B31 #7 mul add def
    /y01 B01 #2 mul B11 #4 mul add B21 #6 mul add B31 #8 mul add def
    /dx x01 x0 sub def
    /dy y01 y0 sub def
}
\begin{pspicture}(-5,-5)(3,7)
\psthick[E=1,stylethick=thicklinebleu,linewidth=0.2]{0}{1}{\BEZIER(-5,0)(-3,7)(3,3)(-2,-5)}%
\psline(-5,0)(-3,7)(3,3)(-2,-5)\psdots[linecolor=red](-5,0)(-3,7)(3,3)(-2,-5)
\end{pspicture}
\end{verbatim}
}
\end{document}
