[pstricks] hyperboloids in pst-solides3d

Michael Sharpe msharpe at ucsd.edu
Tue Jul 13 03:31:41 CEST 2010


On Jul 12, 2010, at 5:52 PM, Zbigniew Nitecki wrote:

>> /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

Google for PostScript tutorials. Adobe made their blue book (cookbook and tutorial) downloadable, and I think also their red book (reference).

Just to translate the segment above as an illustration, 

/z0 h neg div def

says that the PostScript variable z0 is defined to be -h/2. There follows a for loop in which all the steps within the outermost braces are run with a control variable initial value a, incrementing by -1 at each step, terminating at 0. Before each loop, the control variable is placed on the stack.

The repeated material is:

Define the PostScript variable k to be the control variable (that's the purpose of exch, so that if, for example, the control variable value were 4, the stack would look like ... 4 /k exch def, and after executing exch, it would be /k 4 def, defining k as 4. Then there is an inner loop using a control variable that starts at 0, increments by 1 and terminates at b-1, executing the material inside the inner braces with i set to the inner control variable (that's the function of /i exch def). The r is defined as sqrt(((z0+h*k/a)^2)/4+1) and so on (exercise for you.)

Michael


More information about the PSTricks mailing list