[pstricks] pst-Solides3d: fusion of an ellipsoid with an vector

robert.fischer10 at arcor.de robert.fischer10 at arcor.de
Thu Jul 16 15:16:08 CEST 2009


Hello,

are following statements correct?
1) the transform option is not only restricted to the applied object. 
Transform effects all solides within \psset{solidmemory} and
\composeSolid environment
2) with \psSolid[object=vecteur, (or line)... no fusion can be build up. 
But this can make sense: 
by using transparency (opacity), the vector is also visible within the solid and behind
the solid in different gray scales. Therefore it is possible to see the 
intersection point between a vector and the surface of a more complex solid
without doing any further calculations.
3) Suggestion: Building up of an own solides-object (MyVecteur3D) consisting of a cylinder
and a cone for enabling transparency. Test example for fusion with an ellipsoid is below 
Maybe parts of the code can be done in a more easier/proper way. But for the moment it
works (see also attachment for PDF output)

Example for item 1:
===================
a)result as expected
--------------------

\documentclass{minimal}
\usepackage{pst-pdf}
\usepackage{pstricks}
\usepackage{pst-solides3d}
\usepackage{pstricks-add}
\pagestyle{empty}

\begin{document}

\begin{minipage}{\textwidth}
	\psset{lightsrc=viewpoint,lightintensity=1.2,Decran=17}
	\begin{pspicture}(-2,-2)(2,3)
		\psgrid[gridcolor=gray,subgridcolor=lightgray]
		\psSolid[object=sphere,
			r=1,mode=4,%ngrid=25 40
			transform={1 1 2 scaleOpoint3d},
			fillcolor=gray,incolor=gray!10,%hollow,
			linewidth=0.5\pslinewidth,
			action=draw**,name=MyEllipsoid](0,0,0)
		\psSolid[object=vecteur,
			definition={[0.08 0.25]},args=0 2.5 2.5,
			action=draw**,name=MyVector](0,0,0)
%		%Point for Test
		\psSolid[object=point,args=0 2.5 2.5]
		%Axes
		\axesIIID[showOrigin=true,axisnames={x,y,z},
			arrowinset=0,arrowscale=1.5](1,1,2)(2,2,3)
		\end{pspicture}
	\end{minipage}
\end{document}


b)vector is also scaled (compare with 'point for test')
-------------------------------------------------------

\documentclass{minimal}
\usepackage{pst-pdf}
\usepackage{pstricks}
\usepackage{pst-solides3d}
\usepackage{pstricks-add}
\pagestyle{empty}

\begin{document}

\begin{minipage}{\textwidth}
	\psset{lightsrc=viewpoint,lightintensity=1.2,Decran=17}
	\begin{pspicture}(-2,-2)(2,3)
		\psgrid[gridcolor=gray,subgridcolor=lightgray]
		\psset{solidmemory}
		\psSolid[object=sphere,
			r=1,mode=4,%ngrid=25 40
			transform={1 1 2 scaleOpoint3d},
			fillcolor=gray,incolor=gray!10,%hollow,
			linewidth=0.5\pslinewidth,
			action=draw**,name=MyEllipsoid](0,0,0)
		\psSolid[object=vecteur,
			definition={[0.08 0.25]},args=0 2.5 2.5,
			action=draw**,name=MyVector](0,0,0)
%		%Point for Test
		\psSolid[object=point,args=0 2.5 2.5]
		%Axes
		\axesIIID[showOrigin=true,axisnames={x,y,z},
			arrowinset=0,arrowscale=1.5](1,1,2)(2,2,3)
		\end{pspicture}
	\end{minipage}
\end{document}

small remark to the previous coding:
		\composeSolid
%		%Point for Test
		\psSolid[object=point,args=0 2.5 2.5]
		%Axes
		\axesIIID[showOrigin=true,axisnames={x,y,z},
			arrowinset=0,arrowscale=1.5](1,1,2)(2,2,3)
=> shifts ellipsoid and vector to the right (compared to psgrid)

%		%Point for Test
		\psSolid[object=point,args=0 2.5 2.5]
		%Axes
		\axesIIID[showOrigin=true,axisnames={x,y,z},
			arrowinset=0,arrowscale=1.5](1,1,2)(2,2,3)
		\composeSolid
=> no shift of ellipsoid and vector


c)possible solutions
--------------------

\documentclass{minimal}
\usepackage{pst-pdf}
\usepackage{pstricks}
\usepackage{pst-solides3d}
\usepackage{pstricks-add}
\pagestyle{empty}

\begin{document}

\begin{minipage}{\textwidth}	
	\psset{lightsrc=viewpoint,lightintensity=1.2,Decran=17}
	\begin{pspicture}(-2,-2)(2,3)
		\psgrid[gridcolor=gray,subgridcolor=lightgray]
		\psset{solidmemory}
		\psSolid[object=sphere,
			r=1,mode=4,%ngrid=25 40
			transform={1 1 2 scaleOpoint3d},
			fillcolor=gray,incolor=gray!10,%hollow,
			linewidth=0.5\pslinewidth,
			action=draw**,name=MyEllipsoid](0,0,0)
		\psSolid[object=vecteur,
			definition={[0.08 0.25]},args=0 2.5 2.5,
			transform={1 1 1 scaleOpoint3d},
			action=draw**,name=MyVector](0,0,0)
%		%Point for Test
		\psSolid[object=point,args=0 2.5 2.5]
		%Axes
		\axesIIID[showOrigin=true,axisnames={x,y,z},
			arrowinset=0,arrowscale=1.5](1,1,2)(2,2,3)
		\end{pspicture}
	\end{minipage}
\end{document}

or

\documentclass{minimal}
\usepackage{pst-pdf}
\usepackage{pstricks}
\usepackage{pst-solides3d}
\usepackage{pstricks-add}
\pagestyle{empty}

\begin{document}

\begin{minipage}{\textwidth}	
	\psset{lightsrc=viewpoint,lightintensity=1.2,Decran=17}
	\begin{pspicture}(-2,-2)(2,3)
		\psgrid[gridcolor=gray,subgridcolor=lightgray]
		\psset{solidmemory}
		\psset{transform={1 1 2 scaleOpoint3d}}
		\psSolid[object=sphere,
			r=1,mode=4,%ngrid=25 40
			fillcolor=gray,incolor=gray!10,%hollow,
			linewidth=0.5\pslinewidth,
			action=draw**,name=MyEllipsoid](0,0,0)
		\psset{transform={1 1 1 scaleOpoint3d}}
		\psSolid[object=vecteur,
			definition={[0.08 0.25]},args=0 2.5 2.5,
			action=draw**,name=MyVector](0,0,0)
%		%Point for Test
		\psSolid[object=point,args=0 2.5 2.5]
		%Axes
		\axesIIID[showOrigin=true,axisnames={x,y,z},
			arrowinset=0,arrowscale=1.5](1,1,2)(2,2,3)
		\end{pspicture}
	\end{minipage}
\end{document}




Example for item 2:
===================
a)this is not working: error message
------------------------------------

Error: /typecheck in --get--
Operand stack:
   --nostringval--   0   --nostringval--   --nostringval--   2.5   S1   2.5   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   false   1   %stopped_push   1905   1   3   %oparray_pop   1904   1   3   %oparray_pop   1888   1   3   %oparray_pop   1771   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   2   --nostringval--   %repeat_continue   --nostringval--
Dictionary stack:
   --dict:1153/1684(ro)(G)--   --dict:0/20(G)--   --dict:87/200(L)--   --dict:778/1012(L)--   --dict:101/300(L)--   --dict:39/200(L)--   --dict:182/200(L)--   --dict:778/1012(L)--   --dict:2/11(L)--   --dict:2/5(L)--
Current allocation mode is local


\documentclass{minimal}
\usepackage{pst-pdf}
\usepackage{pstricks}
\usepackage{pst-solides3d}

\pagestyle{empty}

\begin{document}

\begin{minipage}{\textwidth}	
	\psset{lightsrc=viewpoint,lightintensity=1.2,Decran=17}
	\begin{pspicture}(-2,-2)(2,3)
		\psgrid[gridcolor=gray,subgridcolor=lightgray]
		\psset{solidmemory}
		\psset{transform={1 1 2 scaleOpoint3d}}
		\psSolid[object=sphere,
			r=1,mode=4,%ngrid=25 40
			fillcolor=gray,incolor=gray!10,%hollow,
			linewidth=0.5\pslinewidth,
			action=none,name=MyEllipsoid](0,0,0)
		\psset{transform={1 1 1 scaleOpoint3d}}
		\psSolid[object=vecteur,
			definition={[0.08 0.25]},args=0 2.5 2.5,
			action=none,name=MyVector](0,0,0)
		\psSolid[object=fusion,
			base=MyEllipsoid MyVector,
			opacity=0.6,
			action=draw**](0,0,0)
%		%Point for Test
		\psSolid[object=point,args=0 2.5 2.5]
		%Axes
		\axesIIID[showOrigin=true,axisnames={x,y,z},
			arrowinset=0,arrowscale=1.5](1,1,2)(2,2,3)
		\composeSolid
		\end{pspicture}
	\end{minipage}
\end{document}

Example for item 3:
===================

creation of an own 3D vector
-------------------------------
according to the attachment (scaling pdf to 300) you see different gray scales for
the vector inside the ellipsoid or completely behind the ellipsoid.

\documentclass{minimal}
\usepackage{pst-pdf}
\usepackage{pstricks}
\usepackage{pst-solides3d}
\usepackage{pstricks-add}
\pagestyle{empty}
%
%Own Solides 3D Objects (C:\Program Files\MiKTeX 2.7\dvips\pst-solides3d)
\pstheader{solidesMyObj.pro}
\addtosolideslistobject{MyVector3D}


\begin{document}
\begin{minipage}{\textwidth}	
	\psset{lightsrc=viewpoint,lightintensity=1.2,Decran=17}
	\begin{pspicture}(-2,-2)(2,3)
		\psgrid[gridcolor=gray,subgridcolor=lightgray]
		\psset{solidmemory}
		\psset{transform={1 1 2 scaleOpoint3d}}
		\psSolid[object=sphere,
			r=1,mode=4,%ngrid=25 40
			fillcolor=gray!40,incolor=gray!10,hollow,
			linewidth=0.5\pslinewidth,
			action=none,name=MyEllipsoid](0,0,0)
		\psset{transform={1 1 1 scaleOpoint3d}}
			\psSolid[object=MyVector3D,
				h=3,r=0.02,R=0.1,mode=4,
				RotY=-90,RotZ=20,
				fcol=0 (Gray),fillcolor=black,
				action=none,name=MyVectorA]
			\psSolid[object=MyVector3D,
				h=2,r=0.02,R=0.1,mode=4,
				RotX=-70,
				fcol=0 (Gray),fillcolor=black,
				action=none,name=MyVectorB]
		\psSolid[object=fusion,
			base=MyEllipsoid MyVectorA MyVectorB,
			linewidth=0.1\pslinewidth,opacity=0.5,
			action=draw**](0,0,0)
		%Axes
		\axesIIID[showOrigin=true,axisnames={x,y,z},
			arrowinset=0,arrowscale=1.5](1,1,2)(2,2,3)
		\composeSolid
		\end{pspicture}
	\end{minipage}
\end{document}

using following solidesMyObj.pro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%             procedures pour \psSolid               %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/newMyVector3D {
	4 dict begin
		[[/n2 /n1] [1 6] [1 8] [1 10] [3 12] [5 18]] gestionsolidmode
		/MyArrowLength{R 2.5 mul}def
		/MyArrowLS{h MyArrowLength sub}def
		MyArrowLS R h [n2 n1] newcone
%		dup 0 (Gray) solidputfcolor %works not (face 0 of cone to be gray)
		0 r MyArrowLS [n2 n1] newcylindre
		solidfuz
	end
} def

/newMyVector3Dcreux {
	4 dict begin
		[[/n2 /n1] [1 6] [1 8] [1 10] [3 12] [5 18]] gestionsolidmode
		/MyArrowLength{R 2.5 mul}def
		/MyArrowLS{h MyArrowLength sub}def
		0 r MyArrowLS [n2 n1] newcylindre
		MyArrowLS R h [n2 n1] newconecreux
		solidfuz
	end
} def

/pst-MyVector3D{
   /save-MyVector3Dhollow solidhollow def
   tx at Dict /function known {
      range aload pop function cvx {axe} h ngrid newMyVector3D
      tx at Dict /function undef
      /solidhollow true def
   } {
      R r h
      ngrid length 2 eq {
         ngrid
      } {
         {Mode}
      } ifelse
      solidhollow {
         newMyVector3Dcreux
      } {
         newMyVector3D
      } ifelse
   } ifelse
   gere_pstricks_opt
   /solidhollow save-MyVector3Dhollow store
}def

-------------- next part --------------
A non-text attachment was scrubbed...
Name: M01.pdf
Type: application/pdf
Size: 38201 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20090716/33cfac5c/attachment-0001.pdf>


More information about the PSTricks mailing list