[pstricks] hyperboloids in pst-solides3d

Michael Sharpe msharpe at ucsd.edu
Mon Jul 12 23:37:42 CEST 2010


On Jul 12, 2010, at 12:49 PM, Zbigniew Nitecki wrote:

> I want to draw (in one pspicture) the level surfaces of f(x,y,z)=x^2+y^2-z^2 
> for the values -1,0, and 1.  
> 
> My attempt to do this with \parametricplotThreeD is not so successful:  either I have
> a collection of lines (and difficulty hiding some) or if I use enough plotpoints, the 
> inside stuff is totally wiped out.  So I'm trying to see if I can do it more easily in
> pst-solides3d.
> 
> The cone for 0 is easy.  I tried to understand from
> the example at the end of section 6.6.4, p. 90 in the (English) documentation for
> pst-solides-3d how to draw a hyperboloid of one sheet in this system, but
> I need someone to parse for me the function definitions embedded in it.
> 
> Here is the code in the example:
> 
>> \begin{pspicture*}(-5,-5)(3,5) \psSolid[object=new,fillcolor=red!50,incolor=yellow,
>> hollow, a=10, %% nb d’etages b=20, %% diviseur de 360, nb de meridiens h=8, %% hauteur action=draw**,sommets=
>> /z0 h neg 2 div def a-10{
>> /k exch def 01b1 sub {
>> /i exch def /r z0 h a div k mul add dup mul 4 div 1 add sqrt def 360 b idiv i mul cos r mul 360 b idiv i mul sin r mul z0 h a div k mul add
>> } for } for, faces={
>> 0 1 a 1 sub { /k exch def k b mul 1 add 1 k 1 add b mul 1 sub { /i exch def [i i 1 sub b i add 1 sub b i add]
>> } for [k b mul k 1 add b mul 1 sub k 2 add b mul 1 sub k 1
>> add b mul] }for
>> }] \end{pspicture*}
> 
> 
> 
> I am having trouble understanding the structure of lines 3-8.
> 
> Can anyone explain it for me?  I have (limited) experience with postscript, but none with jps.

Your source code doesn't agree with the example---there may be a problem here copying from a pdf document. It should read

\begin{pspicture*}(-5,-5)(3,5) 
\psSolid[object=new,fillcolor=red!50,incolor=yellow,
hollow, a=10, %% nb d’etages 
b=20, %% diviseur de 360, nb de meridiens 
h=8, %% hauteur 
action=draw**,
sommets=
/z0 h neg 2 div def a -1 0 {
/k exch def 0 1 b 1 sub {
/i exch def /r z0 h a div k mul add dup mul 4 div 1 add sqrt def 360 b idiv i mul cos r mul 360 b idiv i mul sin r mul z0 h a div k mul add
 } for 
} for, 
faces={
0 1 a 1 sub { /k exch def k b mul 1 add 1 k 1 add b mul 1 sub { /i exch def [i i 1 sub b i add 1 sub b i add]
} for [k b mul k 1 add b mul 1 sub k 2 add b mul 1 sub k 1 add
b mul] 
 } for
 }]
\end{pspicture*}


Michael




More information about the PSTricks mailing list