[pstricks] dropped cells in pst3d-solides

Zbigniew Nitecki zbigniew.nitecki at tufts.edu
Thu Jul 15 22:32:45 CEST 2010


I am trying to draw in one figure three different level surfaces of f(x,y,z), for two such functions,
the first is 4(x^2+y^2)-z^2  (for values f(x,y,z)=-16, 0, 16)
the second is  x^2+y^2-z^2  (for values f(x,y,z)=-1, 0, 1).
The first comes out fine, while the second has some cells unpainted (in some cases, the surface underneath shows through)
The only difference between the two sets of code is the change in the function (changed lines noted in code that follows).
Can anyone explain the cause of this?


First picture (which is OK):

and the second, with dropped cells:

The code for the first(I have cut out the package calls and float) is:
******************************************************************************
> \begin{pspicture}(-5,-5.0)(3,5.5) 
> \psset{solidmemory}
> \psset{unit=0.75}
> \psset{lightsrc=50 -20 50,viewpoint=50 -20 30 rtp2xyz,
> 	Decran=50}
> \psSolid
> [
> 	object=new,
> 	fillcolor=gray!65,
> 	incolor=gray!20,
> 		hollow, 
> 	a=10, %% nb d’etages 
> 	b=20, %% diviseur de 360, nb de meridiens 
> 	h=8, %% hauteur
> 	sommets=
> 		/z0 h neg 2 div def 	%z0:=-h/2
> 		a -1 0 
> 		{
> 			/k exch def	%k:=counter1
> 			0 1 b 1 sub 				
> 			%stack is a  0  0  1  b-1
> 				{
> 					/i exch def 		%i:=counter2
> 					/r z0 h a div 
> 						 k mul 
> 						add 
> 						dup mul 
> %						1 add								%THIS LINE IS WHAT APPEARS AT THIS POSITION  IN PLACE OF THE NEXT TWO
> 						4 div 
> 						4 add 
> 						sqrt 
> 						def 
> 								%r:=\sqrt{(({hk/a}+z0)^2)/4+4}
> 					360 b idiv 
> 					i mul 
> 					cos r mul 		%add to stack r*cos([360/b]i)
> 					360 b idiv 
> 					i mul 
> 					sin r mul 		%add to stack r*sin([360/b]i)
> 					z0 h a div 
> 					k mul 
> 					add			%add to stack (hk/a)+z0
> 				} for 
> 				% stack is 0 0 1 b-1 {r*cos([360/b]i) r*sin([360/b]i) (hk/a)+z0}
> 				% so: for counter2 starting at 0
> 				%	incremented by 1
> 				%	until b-1
> 				%	calculate   r*cos([360/b]i) r*sin([360/b]i) (hk/a)+z0
> 		} for
> 		% stack is a -1 0
> 		% so: for counter1 starting at a
> 		% decreased by 1
> 		% until 0
> 		% do the calculation of the three quantities above (for the values in that loop)
> 	, 
> 	faces=
> 	{
> 		0 1 a 1 sub
> 		% stack is 0 1 a-1 
> 		{ 
> 			/k exch def 	% k:=counter1
> 				k b mul 
> 				1 add 	% kb+1
> 				1 
> 				k 1 add
> 				b mul 	
> 				1 sub	 % (k+1)b-1
> 				% stack is kb+1  1 (k+1)b-1
> 				{ 
> 					/i exch def %i=counter1?
> 					[
> 						i 		
> 						i 1 sub		% i-1
> 						b i add 1 sub 	% b+i-1
> 						b i add		%b+i
> 					]
> 				} for 
> 				% for counter2 starting at kb+1
> 				% incremented by 1
> 				% until (k+1)b-1
> 				% calculate the array above
> 				[
> 					k b mul 	% kb
> 					k 1 add 
> 					b mul 		
> 					1 sub 		% (k+1)b-1
> 					k 2 add 
> 					b mul 
> 					1 sub 		% (k+2)b-1
> 					k 1 add
> 					b mul		% (k+1)b
> 				] 
> 		} for
> 		% for counter1 starting at 0
> 		% incremented by 1
> 		% until a-1
> 		% calculate the array (4 elements) above
> 	}, 
> 	rm=18 19 38 39 58 59  78 79  98 99 118 119 138 139 158 159 178 179 198 199, 
> 	action=none,
> 	name=outer,
> ]
> %
> %
> %%
> \psSolid
> [
> 	object=new,
> 	fillcolor=red!65,
> 	incolor=red!20,
> 		hollow, 
> 	a=10, %% nb d’etages 
> 	b=20, %% diviseur de 360, nb de meridiens 
> 	h=10, %% hauteur
> %	action=none,
> %	name=middle,
> 	sommets=
> 		/z0 h neg 2 div def 	%z0:=-h/2
> 		a -1 0 
> 		{
> 			/k exch def	%k:=counter1
> 			0 1 b 1 sub 				
> 			%stack is a  0  0  1  b-1
> 				{
> 					/i exch def 		%i:=counter2
> 					/r z0 h a div 
> 						 k mul 
> 						add 
> 						dup mul 
> 						4 div 
> %						4 add 												%THIS IS COMMENTED OUT FROM PREVIOUS PSSOLID (LEVEL SET FOR 0 INSTEAD OF 16)
> 						sqrt 
> 						def 
> 								%r:=\sqrt{(({hk/a}+z0)^2)/4}
> 					360 b idiv 
> 					i mul 
> 					cos r mul 		%add to stack r*cos([360/b]i)
> 					360 b idiv 
> 					i mul 
> 					sin r mul 		%add to stack r*sin([360/b]i)
> 					z0 h a div 
> 					k mul 
> 					add			%add to stack (hk/a)+z0
> 				} for 
> 				% stack is 0 0 1 b-1 {r*cos([360/b]i) r*sin([360/b]i) (hk/a)+z0}
> 				% so: for counter2 starting at 0
> 				%	incremented by 1
> 				%	until b-1
> 				%	calculate   r*cos([360/b]i) r*sin([360/b]i) (hk/a)+z0
> 		} for
> 		% stack is a -1 0
> 		% so: for counter1 starting at a
> 		% decreased by 1
> 		% until 0
> 		% do the calculation of the three quantities above (for the values in that loop)
> 	, 
> 	faces=
> 	{
> 		0 1 a 1 sub
> 		% stack is 0 1 a-1 
> 		{ 
> 			/k exch def 	% k:=counter1
> 				k b mul 
> 				1 add 	% kb+1
> 				1 
> 				k 1 add
> 				b mul 	
> 				1 sub	 % (k+1)b-1
> 				% stack is kb+1  1 (k+1)b-1
> 				{ 
> 					/i exch def %i=counter1?
> 					[
> 						i 		
> 						i 1 sub		% i-1
> 						b i add 1 sub 	% b+i-1
> 						b i add		%b+i
> 					]
> 				} for 
> 				% for counter2 starting at kb+1
> 				% incremented by 1
> 				% until (k+1)b-1
> 				% calculate the array above
> 				[
> 					k b mul 	% kb
> 					k 1 add 
> 					b mul 		
> 					1 sub 		% (k+1)b-1
> 					k 2 add 
> 					b mul 
> 					1 sub 		% (k+2)b-1
> 					k 1 add
> 					b mul		% (k+1)b
> 				] 
> 		} for
> 		% for counter1 starting at 0
> 		% incremented by 1
> 		% until a-1
> 		% calculate the array (4 elements) above
> 	}, 
> 	rm=18 19 38 39 58 59  78 79  98 99 118 119 138 139 158 159 178 179 198 199, 
> 	action=none,
> 	name=midcone,
> ]
> %
> %%
> \defFunction{hypup}(u,v)
> 	{u v cos mul}
> 	{u v sin mul}
> 	{u dup mul 4 add sqrt 2 mul}										%THIS LINE IS CHANGED IN OTHER CODE
> \psSolid[
> 	object=surfaceparametree,
> 	base=0 2.5 0 360,
> 	fillcolor=blue!50,
> 	incolor=blue!20,
> 	function=hypup,
> 	ngrid=10 20,
> 	action=none,
> 	name=inner1,
> ]
> \defFunction{hypdown}(u,v)
> 	{u v cos mul}
> 	{u v sin mul}
> %	{u dup mul 1 add sqrt neg}											%THIS LINE APPEARS IN OTHER CODE I N PLACE OF THE NEXT ONE
> 	{u dup mul 4 add sqrt 2 mul neg}
> \psSolid[
> 	object=surfaceparametree,
> 	base=0 2.5 0 360,
> 	fillcolor=blue!50,
> 	incolor=blue!20,
> 	function=hypdown,
> 	ngrid=10 20,
> 	action=none,
> 	name=inner2,
> ]
> ]\psSolid[
> 	object=fusion,
> 	action=draw**,
> 	base=outer midcone inner1 inner2, 
> ]
> %
> \composeSolid
> \end{pspicture}

*******************************************************************************************************
and for the second, it is:

********************************************************************************************************
\begin{pspicture}(-5,-6.5)(3,6.5) 
\psset{solidmemory}
\psset{unit=0.75}
\psset{lightsrc=50 -20 50,viewpoint=50 -20 30 rtp2xyz,
	Decran=50}
\psSolid
[
	object=new,
	fillcolor=gray!65,
	incolor=gray!20,
		hollow, 
	a=10, %% nb d’etages 
	b=20, %% diviseur de 360, nb de meridiens 
	h=8, %% hauteur
	sommets=
		/z0 h neg 2 div def 	%z0:=-h/2
		a -1 0 
		{
			/k exch def	%k:=counter1
			0 1 b 1 sub 				
			%stack is a  0  0  1  b-1
				{
					/i exch def 		%i:=counter2
					/r z0 h a div 
						 k mul 
						add 
						dup mul 
						1 add															%CHANGE HERE FROM PREVIOUS
%						4 div 
%						4 add 
						sqrt 
						def 
								%r:=\sqrt{(({hk/a}+z0)^2)/4+4}
					360 b idiv 
					i mul 
					cos r mul 		%add to stack r*cos([360/b]i)
					360 b idiv 
					i mul 
					sin r mul 		%add to stack r*sin([360/b]i)
					z0 h a div 
					k mul 
					add			%add to stack (hk/a)+z0
				} for 
				% stack is 0 0 1 b-1 {r*cos([360/b]i) r*sin([360/b]i) (hk/a)+z0}
				% so: for counter2 starting at 0
				%	incremented by 1
				%	until b-1
				%	calculate   r*cos([360/b]i) r*sin([360/b]i) (hk/a)+z0
		} for
		% stack is a -1 0
		% so: for counter1 starting at a
		% decreased by 1
		% until 0
		% do the calculation of the three quantities above (for the values in that loop)
	, 
	faces=
	{
		0 1 a 1 sub
		% stack is 0 1 a-1 
		{ 
			/k exch def 	% k:=counter1
				k b mul 
				1 add 	% kb+1
				1 
				k 1 add
				b mul 	
				1 sub	 % (k+1)b-1
				% stack is kb+1  1 (k+1)b-1
				{ 
					/i exch def %i=counter1?
					[
						i 		
						i 1 sub		% i-1
						b i add 1 sub 	% b+i-1
						b i add		%b+i
					]
				} for 
				% for counter2 starting at kb+1
				% incremented by 1
				% until (k+1)b-1
				% calculate the array above
				[
					k b mul 	% kb
					k 1 add 
					b mul 		
					1 sub 		% (k+1)b-1
					k 2 add 
					b mul 
					1 sub 		% (k+2)b-1
					k 1 add
					b mul		% (k+1)b
				] 
		} for
		% for counter1 starting at 0
		% incremented by 1
		% until a-1
		% calculate the array (4 elements) above
	}, 
	rm=18 19 38 39 58 59  78 79  98 99 118 119 138 139 158 159 178 179 198 199, 
	action=none,
	name=outer,
]
%
%
%%
\psSolid
[
	object=new,
	fillcolor=red!65,
	incolor=red!20,
		hollow, 
	a=10, %% nb d’etages 
	b=20, %% diviseur de 360, nb de meridiens 
	h=10, %% hauteur
%	action=none,
%	name=middle,
	sommets=
		/z0 h neg 2 div def 	%z0:=-h/2
		a -1 0 
		{
			/k exch def	%k:=counter1
			0 1 b 1 sub 				
			%stack is a  0  0  1  b-1
				{
					/i exch def 		%i:=counter2
					/r z0 h a div 
						 k mul 
						add 
						dup mul 
%						4 div 															%CHANGE HERE FROM PREVIOUS
%						4 add 
						sqrt 
						def 
								%r:=\sqrt{(({hk/a}+z0)^2)/4}
					360 b idiv 
					i mul 
					cos r mul 		%add to stack r*cos([360/b]i)
					360 b idiv 
					i mul 
					sin r mul 		%add to stack r*sin([360/b]i)
					z0 h a div 
					k mul 
					add			%add to stack (hk/a)+z0
				} for 
				% stack is 0 0 1 b-1 {r*cos([360/b]i) r*sin([360/b]i) (hk/a)+z0}
				% so: for counter2 starting at 0
				%	incremented by 1
				%	until b-1
				%	calculate   r*cos([360/b]i) r*sin([360/b]i) (hk/a)+z0
		} for
		% stack is a -1 0
		% so: for counter1 starting at a
		% decreased by 1
		% until 0
		% do the calculation of the three quantities above (for the values in that loop)
	, 
	faces=
	{
		0 1 a 1 sub
		% stack is 0 1 a-1 
		{ 
			/k exch def 	% k:=counter1
				k b mul 
				1 add 	% kb+1
				1 
				k 1 add
				b mul 	
				1 sub	 % (k+1)b-1
				% stack is kb+1  1 (k+1)b-1
				{ 
					/i exch def %i=counter1?
					[
						i 		
						i 1 sub		% i-1
						b i add 1 sub 	% b+i-1
						b i add		%b+i
					]
				} for 
				% for counter2 starting at kb+1
				% incremented by 1
				% until (k+1)b-1
				% calculate the array above
				[
					k b mul 	% kb
					k 1 add 
					b mul 		
					1 sub 		% (k+1)b-1
					k 2 add 
					b mul 
					1 sub 		% (k+2)b-1
					k 1 add
					b mul		% (k+1)b
				] 
		} for
		% for counter1 starting at 0
		% incremented by 1
		% until a-1
		% calculate the array (4 elements) above
	}, 
	rm=18 19 38 39 58 59  78 79  98 99 118 119 138 139 158 159 178 179 198 199, 
	action=none,
	name=midcone,
]
%
%%
\defFunction{hypup}(u,v)
	{u v cos mul}
	{u v sin mul}
	{u dup mul 1 add sqrt }														%CHANGE HERE FROM PREVIOUS
\psSolid[
	object=surfaceparametree,
	base=0 2.5 0 360,
	fillcolor=blue!50,
	incolor=blue!20,
	function=hypup,
	ngrid=10 20,
	action=none,
	name=inner1,
]
\defFunction{hypdown}(u,v)
	{u v cos mul}
	{u v sin mul}
	{u dup mul 1 add sqrt neg}														%CHANGE HERE FROM PREVIOUS
\psSolid[
	object=surfaceparametree,
	base=0 2.5 0 360,
	fillcolor=blue!50,
	incolor=blue!20,
	function=hypdown,
	ngrid=10 20,
	action=none,
	name=inner2,
]
]\psSolid[
	object=fusion,
	action=draw**,
	base=outer midcone inner1 inner2, 
]
\composeSolid
%
\end{pspicture}
***************************************************************************************************


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/20100715/bf1c03dc/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pst3d test 1.pdf
Type: application/pdf
Size: 33836 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20100715/bf1c03dc/attachment-0002.pdf>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20100715/bf1c03dc/attachment-0004.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pst3d test 2.pdf
Type: application/pdf
Size: 32977 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20100715/bf1c03dc/attachment-0003.pdf>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20100715/bf1c03dc/attachment-0005.html>


More information about the PSTricks mailing list