3

I want to generate a couple of solids, one inside the other. I know I can do it in pst-solides3d because it of the first picture in the documentation. My intention is to create an ellipsoid inside another ellipsoid, quite simple really

\documentclass{minimal}
\usepackage{pst-solides3d}
\begin{document}
\begin{pspicture}(-5,-4)(5,6)
\psset[pst-solides3d]{viewpoint=20 20 -10 rtp2xyz,Decran=15,lightsrc=viewpoint}
\defFunction{esfera2}(u,v)
{u cos v sin mul 5 mul}
{u sin v sin mul 4 mul}
{v cos           3 mul}
\defFunction{esfera1}(u,v)
{u cos v sin mul 3 mul}
{u sin v sin mul 2 mul}
{v cos           1 mul}
\psSolid[
    object=surfaceparametree,
    base=0 180 0 180,
    incolor=red,
    function=esfera1,
    linewidth=0.5\pslinewidth,
    ngrid=40
]%
\psSolid[
    object=surfaceparametree,
    base=0 180 0 180,
    incolor=white,
    opacity=0.5,
    function=esfera2,
    linewidth=0.5\pslinewidth,
    ngrid=40
]%
\end{pspicture}
\end{document}

My code produces the following result

incorrectly nested ellipsoids

But my target is to make it look like the following picture (if you haven't seen it yet)

Solides3d Manual cover picture

I suppose part of the problem may be that my solids are parametrized surfaces. Any ideas?

Bernard
  • 271,350
hanzo2001
  • 509

1 Answers1

3

You have to build a fusion object (collects all polygon surfaces) and, of course, to rotate the object for a look into the inside:

\documentclass{minimal}
\usepackage{pst-solides3d}
\begin{document}
\begin{pspicture}[solidmemory](-5,-4)(5,6)
\psset{viewpoint=20 -20 10 rtp2xyz,Decran=15,lightsrc=viewpoint,
  linewidth=0.1pt,action=none}
\defFunction{esfera2}(u,v)
  {u cos v sin mul 5 mul}
  {u sin v sin mul 4 mul}
  {v cos           3 mul}
\defFunction{esfera1}(u,v)
  {u cos v sin mul 3 mul}
  {u sin v sin mul 2 mul}
  {v cos           1 mul}
\psSolid[
    object=surfaceparametree,
    base=0 180 0 180,
    incolor=red,
    function=esfera1,
    ngrid=20,name=esfera1
]%
\psSolid[
    object=surfaceparametree,
    base=0 180 0 180,
    incolor=white,
    function=esfera2,
    ngrid=40,name=esfera2
]%
\psSolid[object=fusion,base=esfera1 esfera2,action=draw**]
\end{pspicture}
\end{document}

enter image description here

  • Thank you, as always! I have a series of follow up questions (related to your answer), I'm not sure if I should ask them here or if I should make them as separate questions. – hanzo2001 Sep 03 '14 at 13:12
  • aks a new question. –  Sep 03 '14 at 16:24
  • For some reason I cannot recall my followup questions. I guess this is a case closed – hanzo2001 Sep 03 '14 at 16:59