\documentclass[a4paper]{article}
\usepackage{pst-solides3d,pst-node,multido}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\pagestyle{empty}
\date{30 septembre 2\,006}

\makeatletter
\def\psPoint{\def\pst@par{}\pst@object{psPoint}}
\def\psPoint@i(#1)#2{{% coordonnées cartésiennes
  \begin@ClosedObj
\pnode(!
    \tx@optionssolides
    SolidesDict begin
    #1
   3dto2d cm_1 exch cm_1 exch
   end){#2}%
   \end@ClosedObj
  }\ignorespaces%
}
\makeatother

\def\grille{% quadrillage du plan Oxy
\psPoint(-10 -10 0){A1}\psPoint(10 -10 0){A2}
\psPoint(10 10 0){A3}\psPoint(-10 10 0){A4}
\pspolygon*[linecolor=green!50](A1)(A2)(A3)(A4)
\multido{\ix=-10+1}{21}{%
    \psPoint(\ix\space -10 0){A}
    \psPoint(\ix\space 10 0){B}
    \psline(A)(B)}
\multido{\iy=-10+1}{21}{%
    \psPoint(-10 \iy\space 0){A}
    \psPoint(10 \iy\space 0){B}
    \psline(A)(B)}
    \psPoint(0 0 0){O}
    \psPoint(10 0 0){X}
    \psPoint(0 10 0){Y}
    \psPoint(0 0 10){Z}
    \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(X)
    \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(Y)
    \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(Z)
    \uput[r](X){\textcolor{blue}{$x$}}\uput[u](Y){\textcolor{blue}{$y$}}%
    \uput[r](Z){\textcolor{blue}{$z$}}\uput[u](O){\textcolor{blue}{$O$}}}


\author{JPV}

\title{tests procédure des solides de révolution JPV}

\begin{document}
\maketitle

\section{objet : cylindricalring, 5 exemples}
\begin{enumerate}
\item
Commande pré-définie, l'anneau à section rectangulaire :

\begin{minipage}{0.45\linewidth}
\begin{verbatim}
\newcommand\Section{%
  0 R h 2 div neg % sommet 1
  0 R h 2 div     % sommet 2
  0 r h 2 div     % sommet 3
  0 r h 2 div neg % sommet 4
            }
\end{verbatim}
\end{minipage}
\hfill
\begin{minipage}{0.45\linewidth}
\psset{unit=0.5}
\begin{pspicture}(-5,-3)(5,3)
\pstVerb{/R 4 def /r 2 def /h 2 def}%
\newcommand\RectangularSection{\pspolygon[fillstyle=vlines,linewidth=2\pslinewidth](!R h 2 div neg)(!R h 2 div)(!r h 2 div)(!r h 2 div neg)}
\rput(0,0){\RectangularSection}\rput(-6,0){\RectangularSection}
\psline(-2,1)(2,1)\psline(-2,-1)(2,-1)
\psline[linestyle=dashed,dash=1 0.2 0.05 0.2](0,-3)(0,3)
\psline[linestyle=dashed](-4,0)(4,0)
\psline{->}(0,1.5)(2,1.5)\uput[u](1,1.5){$r$}
\psline{->}(0,2.5)(4,2.5)\uput[u](2,2.5){$R$}
\psline{<->}(5,-1)(5,1)\uput[r](5,0){$h$}
\uput[dr](!R h 2 div neg){1}
\uput[ur](!R h 2 div ){2}
\uput[ul](!r h 2 div ){3}
\uput[dl](!r h 2 div neg){4}
\end{pspicture}
\end{minipage}

\begin{center}
%%
\psset{unit=0.5}
\begin{pspicture}(-5,-6)(5,6)
\psframe(-5,-4)(5,4)
\psset[pst-solides3d]{SphericalCoor=true,viewpoint=50 20 40,Decran=25,lightsrc=10 20 20}
\psSolid[object=cylindricalring,color=cyan,h=3,r1=8,r0=6,RotX=10](0,0,0)
\end{pspicture}
%%
\begin{pspicture}(-5,-6)(5,5)
\psframe(-5,-4)(5,4)
\psset[pst-solides3d]{SphericalCoor=true,viewpoint=50 -20 -40,Decran=25,lightsrc=-10 -20 -20}
\psSolid[object=cylindricalring,color=yellow,h=3,r1=8,r0=6,RotX=90,RotZ=10](0,0,0)
\end{pspicture}
\end{center}
\renewcommand\Section{
         0 R h 2 div neg % sommet 1
         0 R r add 2 div h 2 div % sommet 2
         0 r h 2 div neg % sommet 3
}
\newpage
\item L'anneau à section triangulaire
\begin{verbatim}
\renewcommand\Section{
         0 R h 2 div neg % sommet 1
         0 R r add 2 div h 2 div % sommet 2
         0 r h 2 div neg % sommet 3
}
\end{verbatim}
\begin{center}
%%
\psset{unit=0.5}
\begin{pspicture}(-5,-6)(5,6)
\psframe(-5,-4)(5,4)
\psset[pst-solides3d]{SphericalCoor=true,viewpoint=50 20 40,Decran=25,lightsrc=10 20 20}
\psSolid[object=cylindricalring,color=cyan,h=3,r1=8,r0=4,RotX=10](0,0,0)
\end{pspicture}
%%
\begin{pspicture}(-5,-6)(5,5)
\psframe(-5,-4)(5,4)
\psset[pst-solides3d]{SphericalCoor=true,viewpoint=50 -20 -40,Decran=25,lightsrc=-10 -20 -20}
\psSolid[object=cylindricalring,color=yellow,h=3,r1=8,r0=4,RotX=-90,RotZ=10](0,0,0)
\end{pspicture}
\end{center}
\newpage
\renewcommand\Section{
   /m {90 4 div} bind def
   /Scos {m cos 2 m mul cos add 3 m mul cos add} bind def
   /Z0 {h 4 div} bind def
   /c {Z0 Scos div} bind def
   /Z1 {Z0 c m cos mul add} bind def
   /Z2 {Z1 c m 2 mul cos mul add} bind def
%  /Z3 {Z2 c m 3 mul cos mul add} bind def Z3= h/2
   /R1 {R c m sin mul sub} bind def
   /R2 {R1 c m 2 mul sin mul sub} bind def
   /R3 {R2 c m 3 mul sin mul sub} bind def
   0 R h 4 div neg % 1
   0 R h 4 div % 2
   0 R1 Z1 % 3
   0 R2 Z2 % 4
   0 R3 h 2 div % 5
   0 r h 2 div  % 6
   0 r h 2 div neg  % 7
   0 R3 h 2 div neg % 8
   0 R2 Z2 neg % 9
   0 R1 Z1 neg % 10
   }
\item L'anneau à section ``pneu'' : anneau cylindrique à arêtes chanfreinées.
\begin{verbatim}
\renewcommand\Section{
   /m {90 4 div} bind def
   /Scos {m cos 2 m mul cos add 3 m mul cos add} bind def
   /Z0 {h 4 div} bind def
   /c {Z0 Scos div} bind def
   /Z1 {Z0 c m cos mul add} bind def
   /Z2 {Z1 c m 2 mul cos mul add} bind def
%  /Z3 {Z2 c m 3 mul cos mul add} bind def Z3= h/2
   /R1 {R c m sin mul sub} bind def
   /R2 {R1 c m 2 mul sin mul sub} bind def
   /R3 {R2 c m 3 mul sin mul sub} bind def
   0 R h 4 div neg % 1
   0 R h 4 div % 2
   0 R1 Z1 % 3
   0 R2 Z2 % 4
   0 R3 h 2 div % 5
   0 r h 2 div  % 6
   0 r h 2 div neg  % 7
   0 R3 h 2 div neg % 8
   0 R2 Z2 neg % 9
   0 R1 Z1 neg % 10
   }
\end{verbatim}
\begin{center}
%%
\psset{unit=0.5}
\begin{pspicture}(-5,-6)(5,6)
\psframe(-5,-4)(5,4)
\psset[pst-solides3d]{SphericalCoor=true,viewpoint=50 20 40,Decran=25,lightsrc=10 20 20}
\psSolid[object=cylindricalring,color=cyan,h=3,r1=8,r0=4,RotX=10](0,0,0)
\end{pspicture}
%%
\begin{pspicture}(-5,-6)(5,5)
\psframe(-5,-4)(5,4)
\psset[pst-solides3d]{SphericalCoor=true,viewpoint=50 -20 -40,Decran=25,lightsrc=-10 -20 -20}
\psSolid[object=cylindricalring,color=yellow,h=3,r1=8,r0=4,RotX=-90,RotZ=10](0,0,0)
\end{pspicture}
\end{center}
\newpage
\item pouf
\begin{verbatim}
\psSolid[object=cylindricalring,color=red!50!yellow!30,h=10,r1=6,r0=0.1](0,0,0)
\end{verbatim}
\begin{center}
\begin{pspicture*}(-5,-6)(5,7)
\psframe(-5,-4)(5,7)
\psset[pst-solides3d]{SphericalCoor=true,viewpoint=50 20 20,Decran=25,lightsrc=10 20 20}
\grille
\psSolid[object=cylindricalring,color=red!50!yellow!30,h=10,r1=6,r0=0.1](0,0,5)
\psPoint(0 0 12){Z'}
\psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(Z)(Z')
\uput[u](Z'){\textcolor{blue}{$z$}}
\end{pspicture*}
\end{center}
\newpage
\item les arènes
\begin{verbatim}
\renewcommand\Section{
   360 -20 180{
    /Angle ED
    0 % x=0
    R r sub 2 div Angle cos mul R r add 2 div add % y=(R-r)cos(A)+(R+r)/2
    R r sub 2 div Angle sin mul neg h add % z=-(R-r)sin(A)+h
    } for
   0 r 0
   0 R 0
   }
\end{verbatim}
\renewcommand\Section{
   360 -20 180{
    /Angle ED
    0 % x=0
    R r sub 2 div Angle cos mul R r add 2 div add % y=(R-r)cos(A)+(R+r)/2
    R r sub 2 div Angle sin mul neg h add % z=-(R-r)sin(A)+h
    } for
   0 r 0
   0 R 0
   }
\begin{center}
\begin{pspicture}(-5,-6)(5,5)
\psframe*[linecolor=red!50](-5,-4)(5,4)
\psset[pst-solides3d]{SphericalCoor=true,viewpoint=50 45 45,Decran=25,lightsrc=10 20 20}
\grille
\psSolid[object=cylindricalring,color=blue!50!gray!30,h=4,r1=8,r0=6](0,0,0)
\psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(Z)
\uput[u](Z){\textcolor{blue}{$z$}}
\end{pspicture}
\end{center}
\end{enumerate}
\end{document}
