[pstricks] \psVolume

Herbert Voss Herbert.Voss at fu-berlin.de
Fri Oct 12 23:16:06 CEST 2007


Hamed schrieb:

>  Can any one explain the following code 

\def\psVolume{\pst at object{psVolume}}% 2007-06-23
\def\psVolume at i(#1,#2)#3#4{{%
  \begin at SpecialObj
  \psplot[fillstyle=none]{#1}{#2}{#4}%     original function
  \psplot[fillstyle=none]{#1}{#2}{#4 neg}% mirrored at the x-axis
  \multido{\iA=1+1}{#3}{%	 run it #3 times with increment \A
    \pscustom{%                  to get a closed filled ellipse
      \code{
        /dX #2 #1 sub #3 div def % delta x, the step
        /Start dX \iA\space 1 sub mul #1 add def % xStart
        /End Start dX add def                    % xEnd=xStart+dX
        /Height End Start add 2 div /x ED #4 def } % height=f(x)
         % x is the mean between Start+End
      \psellipticarc(!Start 0)(! Height 8 div Height){90}{270}
      % draw the first falf of the ellipse
      \rlineto(! dX 0)% draw a line in x-direction
      \psellipticarc(!End 0)(! Height 8 div Height){270}{90}
      % draw the other half of the ellipse
      \rlineto(!dX neg 0)}}% draw a line in negative x-direction
  \psset{fillstyle=none}
  \psellipse(#2,0)(!#2 dup #1 sub #3 div 2 div sub /x ED #4 dup 8 div
exch)% draw again the ellipse to get the borderline.

\psset{plotstyle=line,linestyle=dashed,plotpoints=40,dotstyle=*,dotsize=0.5pt}
  \psplot{#1}{#2}{#4}\psplot{#1}{#2}{#4 neg}
  % draw again the curves to get the borderline
  \end at SpecialObj
}\ignorespaces}






More information about the PSTricks mailing list