# [pstricks] definitions inside definitions

Zbigniew Nitecki zbigniew.nitecki at tufts.edu
Thu Aug 5 18:50:12 CEST 2010

```This question regards defining items, specifically functions, in pst3d-solides.

Consider the following code, defining a function of one variable with values in 3-space,
which I want to use in a \pstSolid[object=courbe...(which appears at the end, but is not part of my question):
####################################################################################
> 			\defFunction{Fintp1}(p)%	p=standin for phi, r=standin for rho
> 			{%
> 				/rho 2.29 def %				rho=6
> 			%	Define X
> 				/X %
> 					rho dup dup mul mul 2 div %	rho^{3}/2
> 						p sin dup mul %			sin^{2} phi
> 						p cos mul %				sin^{2} phi cos phi
> 					mul
> 				def %					X=(rho^{3}/2)sin^{2} phi cos phi
> 			%	Define theta
> 				/thet %
> 					X dup dup mul %			X X^{2}
> 						1 sub %				X X^{2}-1
> 						sqrt %
> 							sub %			X-sqrt{X^{2}-1}
> 							arctan %
> 				def %						theta=arctan (X-sqrt{X^{2}-1} )
> 			% 	Define x
> 					rho %
> 						p sin %
> 						thet cos %
> 						mul mul%	x=(rho)(sin phi)(cos theta)
> 			}
> %
> 			{%
> 				/rho 2.29 def %				rho=6
> 			%	Define X
> 				/X %
> 					rho dup dup mul mul 2 div %	rho^{3}/2
> 						p sin dup mul %			sin^{2} phi
> 						p cos mul %				sin^{2} phi cos phi
> 					mul %
> 				def %					X=(rho^{3}/2)sin^{2} phi cos phi
> 			%	Define theta
> 				/thet %
> 					X dup dup mul %			X X^{2}
> 						1 sub %				X X^{2}-1
> 						sqrt %
> 							sub %			X-sqrt{X^{2}-1}
> 							arctan %
> 				def %						theta=arctan (X-sqrt{X^{2}-1} )
> 			% 	Define y
> 					rho %
> 						p sin %
> 						thet sin %
> 						mul mul%			y=(rho)(sin phi)(sin theta)
> 			}
> %
> 				{%
> 					/rho 2.29 def % 					r=2.24
> 			%	Define z
> 					rho p cos mul%			z=(rho)(cos phi)
> 				}
> %
>
> 			\psSolid[object=courbe,
> 				r=0,
> 				linewidth=2 pt,
> 				linecolor=blue,
> 				range=25.435 80.118,
> 				function=Fintp1,
> 				]
>

#############################################################################
The quantity rho has the same definition (fixed numerical value) in all three coordinates,
and the quantities thet and X are each defined exactly the same way in the first and second coordinates
(but used in very slightly different ways in the two coordinates).

Is there a way to structure this so that these three definitions appear only once in the definition of the curve?

I am not quite clear at what level of the definition these definitions are read, so I don't know how to put them in
to a single place so as to apply to all three parts of the function.

Zbigniew Nitecki
Department of Mathematics
Tufts University
Medford, MA 02155

telephones:
Office    (617)627-3843
Dept.    (617)627-3234
Dept. fax    (617)627-3966
http://www.tufts.edu/~znitecki/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20100805/23ecf0b2/attachment.html>
```