7

I am trying to draw a simple cylinder with PSTricks, similar to what is attached. Is there a smart way to do this, or do I just have to manually draw each line? If there is no other way, then it is way to cumbersome and time-consuming for me.

enter image description here

BillyJean
  • 1,743

4 Answers4

7

You can use \psCylinder from pst-3dplot; some examples from the documentation:

\documentclass{article}
\usepackage{pst-3dplot}

\begin{document}

\begin{pspicture}(-3,-2)(3,7)
\psset{Beta=10}
\pstThreeDCoor[zMax=7]
\psCylinder[increment=5]{2}{5}
\end{pspicture}

\begin{pspicture}(-4.5,-1.5)(3,6.8)
\psset{Beta=10}
\pstThreeDCoor[zMax=4]
\pstIIIDCylinder[fillcolor=blue!20,
RotX=45](1,1,0){2}{5}
\end{pspicture}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
5

Here's how you can do this with asymptote:

\documentclass[12pt]{article}
\usepackage{asymptote}

\begin{document}
\begin{figure}
\begin{asy}
settings.outformat="pdf";
settings.render=0;
settings.prc=false;

import solids;
size(200,200);
currentprojection=orthographic(0,2,0);

revolution r=cylinder(O,1,4,(1,0.5,0));
draw(r);
\end{asy}
\end{figure}

\end{document}
Jake
  • 232,450
4

You have the psCylinder command from the pst-3dplotpackage. You give the coordinates of the centre and the radius of the base circle, the height of the cylinder and the angle of vieW. This will give a parallel projection. See § 14-15 of the doc.

For a central projection, you have the pst-solides3d package and a psSolidcommand; you specify the type of object you want to plot (object=cylindr, its parameters (for a cylinder r=… and h =…).

Bernard
  • 271,350
  • Sorry for this partial duplicate: the other answer was published while I was writing mine. I leave it, as another possibility is mentioned. – Bernard Feb 06 '14 at 17:11
4

pst-solides3d allows you to draw the hidden lines using the action=draw key-value:

enter image description here

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

\psset{unit=0.5}
\psset{lightsrc=viewpoint,viewpoint=50 60 25 rtp2xyz,Decran=50}
\begin{pspicture}(-2,-3)(6,6)
  \psSolid[object=cylindre,h=6,r=2,RotY=90,action=draw](0,4,0)
  \psSolid[object=cylindre,h=6,r=2,RotX=-30,action=draw](0,10,0)
\end{pspicture}

\end{document}
Werner
  • 603,163