7

I would like to draw a 'horizontal' cylinder connecting the two upper spheres from Herbert's answer here.

I have looked at the pst-solides3d manual but I cannot find out how to do that.

How do I do that?

2 Answers 2

6

no need for defining a parametric function. Simply rotate the cylinder:

\documentclass{article}
\usepackage{pst-solides3d}

\psset{lightsrc=viewpoint,viewpoint=80 10 10 rtp2xyz,Decran=40}
\begin{document}
 \begin{pspicture}[solidmemory](-4,-4)(14,14)
  \psset{object=sphere,r=2,fillcolor=red!25,action=none}
  \psSolid[object=cylindre,h=6,r=0.5,fillcolor=yellow,name=C](0,0,0)
  \psSolid[name=S1](0,0,0)
  \psSolid[name=S2](0,0,6)
  \psSolid[name=S3](0,6,6)
  \psSolid[object=cylindre,h=8,r=0.5,RotX=-45,
           fillcolor=black!20,name=L1]
  \psSolid[object=cylindre,h=6,r=0.5,RotY=90,RotZ=90,
           fillcolor=green!20,name=L2](0,0,6)
  \psSolid[object=fusion,base=S1 S2 S3 C L1 L2,linewidth=0.2pt,action=draw**]  
 \end{pspicture}
\end{document}

enter image description here

5
  • Nice. Just out of curiosity: Why did you define a function for the slanted cylinder in your original answer? Commented Nov 24, 2013 at 21:29
  • just for fun ...
    – user2478
    Commented Nov 24, 2013 at 21:32
  • @texenthusiast: You'll find a lot of examples in your local TeX distribution: $TEXMF/doc/latex/pstricks-examples/
    – user2478
    Commented Nov 24, 2013 at 21:36
  • @texenthusiast: texdoc refers only to the main documentation. And the quick ref is an additional documentation, like the other ones. What do you mean by "english contents"?
    – user2478
    Commented Nov 25, 2013 at 7:59
  • comedy.dante.de/~herbert/Books For texdoc write to tug.org/mailman/listinfo/texdoc
    – user2478
    Commented Nov 25, 2013 at 14:47
4

The default cylinder shape is vertical. Like the slanted one, you have to specify the horizontal one using a parametric function. Here they are (without the balls):

enter image description here

\documentclass{article}
\usepackage{pst-solides3d}% http://ctan.org/pkg/pst-solides3d

\psset{lightsrc=viewpoint,viewpoint=80 10 10 rtp2xyz,Decran=40}
\begin{document}
 \begin{pspicture}[solidmemory](-4,-4)(14,14)
  \psset{object=sphere,r=2,fillcolor=red!25,action=none}
  \psSolid[object=cylindre,h=6,r=0.5,fillcolor=yellow,name=C](0,0,0)
  %\psSolid[name=S1](0,0,0)
  %\psSolid[name=S2](0,0,6)
  %\psSolid[name=S3](0,6,6)
  \defFunction[algebraic]{FIVa}(t){0}{t}{t}% x(t)=0, y(t)=t, z(t)=t
  \psSolid[object=courbe,range=0 6,ngrid=16 16,function=FIVa,r=0.5,
           fillcolor=black!20,name=L1]
  \defFunction[algebraic]{FIVb}(t){0}{t}{6}% x(t)=0, y(t)=t, z(t)=6
  \psSolid[object=courbe,range=0 6,ngrid=16 16,function=FIVb,r=0.5,
           fillcolor=green!50,name=L2]
%
  \psSolid[object=fusion,base=C L1 L2,linewidth=0.2pt,action=draw**]  
 \end{pspicture}
\end{document}

FIVa is associated with the diagonal cylinder, and FIVb is associated with the horizontal cylinder. The parametric function FIVb(t)=(x(t),y(t),z(t)) has a fixed x and z coordinate. Only the y coordinate changes, making it lay horizontally.


Here's a take on the entire structure at a higher resolution (or ngrid), balls included:

enter image description here

\documentclass{article}
\usepackage{pst-solides3d}% http://ctan.org/pkg/pst-solides3d

\psset{lightsrc=viewpoint,viewpoint=80 10 10 rtp2xyz,Decran=40}
\begin{document}
 \begin{pspicture}[solidmemory](-4,-4)(14,14)
  \psset{object=sphere,r=2,fillcolor=red!25,action=none,ngrid=40 40}
  \psSolid[object=cylindre,h=6,r=0.5,fillcolor=yellow,name=C](0,0,0)
  \psSolid[name=S1](0,0,0)
  \psSolid[name=S2](0,0,6)
  \psSolid[name=S3](0,6,6)
  \defFunction[algebraic]{FIVa}(t){0}{t}{t}% x(t)=0, y(t)=t, z(t)=t
  \psSolid[object=courbe,range=0 6,ngrid=40 40,function=FIVa,r=0.5,
           fillcolor=black!20,name=L1]
  \defFunction[algebraic]{FIVb}(t){0}{t}{6}% x(t)=0, y(t)=t, z(t)=6
  \psSolid[object=courbe,range=0 6,ngrid=40 40,function=FIVb,r=0.5,
           fillcolor=green!50,name=L2]
%
  \psSolid[object=fusion,base=C L1 L2 S1 S2 S3,linewidth=1sp,action=draw**]  
 \end{pspicture}
\end{document}
2
  • I hope you are not offended by me changing the accepted answer to Herbert's. You did exactly what I asked for but Herbert improved on his previous code. Commented Nov 24, 2013 at 21:51
  • 1
    @SvendTveskæg: No problem.
    – Werner
    Commented Nov 24, 2013 at 22:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .