[pstricks] Slices of a solid of revolution
Herbert Voss
LaTeX at zedat.fu-berlin.de
Wed Jun 13 16:20:43 CEST 2007
Hamed wrote:
> Hi everybody,
>
> First of all, thanks a lot for Juergen,
>
> Second, my question was about the slice of a solid of revolution.
>
> I meant can we do the slice for the solid obtained by rotating the region
> bounded by y=x and y=x^2 about the x-axis
>
hope, this helps
Herbert
\documentclass{article}
\usepackage{pst-plot}
\SpecialCoor
\usepackage{multido}
\parindent=0pt
#1: x1; #2: x2: #3: no of steps; #4: equation
\def\psVolume(#1,#2)#3#4{{%
\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 #1 add def
/End Start dX add def
/Height End Start add 2 div /x ED #4 def }
\psellipticarc(!Start 0)(! Height 8 div Height){90}{270}
\rlineto(! dX 0)
\psellipticarc(!End 0)(! Height 8 div Height){270}{90}
\rlineto(!dX neg 0)}}
\psellipticarc(#2,0)(! #2 dup #1 sub #3 div 2 div sub
/x ED x 4 div #4){90}{270}
\psset{plotstyle=line,linestyle=dashed,plotpoints=40,dotstyle=*,dotsize=0.5pt}
\psplot{#1}{#2}{#4}\psplot{#1}{#2}{#4 neg}%
}\ignorespaces}
\begin{document}
\psset{xunit=2}
\begin{pspicture}(-0.5,-4)(4,4)
\psaxes{->}(0,0)(0,-4)(3,4)
\psVolume(0,1){2}{x}
\psVolume(1,2){2}{x dup mul}
\psline(2,0)(3,0)
\end{pspicture}
\begin{pspicture}(-0.5,-4)(4,4)
\psaxes{->}(0,0)(0,-4)(3,4)
\psVolume(0,1){20}{x}
\psVolume(1,2){20}{x dup mul}
\psline(2,0)(3,0)
\end{pspicture}
\end{document}
More information about the PSTricks
mailing list