Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

4 Answers 4

up vote 8 down vote accepted

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

share|improve this answer
    
Thanks. Looking at the first picture, how do I rotate it such that the z-axis is horizontal? –  BillyJean Feb 7 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}
share|improve this answer
1  
Info on compilation sequence: pdflatex --> asy --> pdflatex –  texenthusiast Feb 6 at 18:06

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 =…).

share|improve this answer
    
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 6 at 17:11

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}
share|improve this answer
    
One bad thing in pst-solides3d are the object names which are not in English. –  Who is crazy first Feb 6 at 17:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.