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.
4 Answers
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}
-
Thanks. Looking at the first picture, how do I rotate it such that the z-axis is horizontal? Feb 7, 2014 at 9:25
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}
-
1
You have the psCylinder
command from the pst-3dplot
package. 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 psSolid
command; you specify the type of object you want to plot (object=cylindr, its parameters (for a cylinder r=… and h =…).
-
Sorry for this partial duplicate: the other answer was published while I was writing mine. I leave it, as another possibility is mentioned.– BernardFeb 6, 2014 at 17:11
pst-solides3d
allows you to draw the hidden lines using the action=draw
key-value:
\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}
-
One bad thing in
pst-solides3d
are the object names which are not in English. Feb 6, 2014 at 17:15