# [pstricks] Slices of a solid of revolution

Herbert Voss LaTeX at zedat.fu-berlin.de
Sun Jun 10 11:54:46 CEST 2007

Chicoine Martin wrote:
> I would like to draw the slices of a solid of revolution as in the following example :
>
> http://www.seg.etsmtl.ca/Math/Animations/disqRMin1.htm
>
> Does something exist that could do it?
>

We can make it exist ... :-)

Herbert

\documentclass{article}
\usepackage{pst-plot}
\SpecialCoor
\usepackage{multido}
\parindent=0pt

\def\psVolume(#1,#2)#3#4{{
\begin{pspicture}(-1,-2.1)(5,2.1)
\psaxes{->}(0,0)(0,-2)(5,2)
\psplot{#1}{#2}{#4}\psplot{#1}{#2}{#4 neg}
\multido{\iA=1+1}{#3}{%
\pscustom[fillcolor=green,fillstyle=solid]{%
\code{
/dX #2 #1 sub #3 div def
/Start dX \iA\space 1 sub mul def
/Height End Start add 2 div /x ED #4 def }
\psellipticarc(!Start 0)(!0.25 Height){90}{270}
\rlineto(! dX 0)
\psellipticarc(!End 0)(!0.25 Height){270}{90}
\rlineto(!dX neg 0)}}
\psline{->}(#2,0)(5,0)
\psellipticarc(#2,0)(!0.25 #2 dup #1 sub #3 div 2 div sub
TeXDict begin /x ED #4 end){90}{270}

\psset{plotstyle=line,linestyle=dashed,plotpoints=40,dotstyle=*,dotsize=0.5pt}
\psplot{#1}{#2}{#4}\psplot{#1}{#2}{#4 neg}
\end{pspicture}
}}

\begin{document}

\psVolume(0,4){1}{x sqrt}\\
\psVolume(0,4){2}{x sqrt}\\
\psVolume(0,4){4}{x sqrt}\\
\psVolume(0,4){8}{x sqrt}\\
\psVolume(0,4){16}{x sqrt}\\
\psVolume(0,4){32}{x sqrt}

\end{document}