3

I would like to draw a cylinder , a circle and plane. Here is what I have so far:

\begin{tikzpicture}
\fill[top color=blue!50!,bottom color=blue!20! ,middle  color=red!20!,shading=axis,opacity=0.6] (0,0) circle (2cm and 0.5cm);
\fill[left color=blue!50!,right color=blue!20! ,middle color=red!20! ,shading=axis,opacity=0.6] (2,0) -- (2,6) arc (360:180:2cm and 0.5cm) -- (-2,0) arc (180:360:2cm and 0.5cm);
\fill[top color=blue!50!,bottom color=blue!20,middle color=red!20! ,shading=axis,opacity=0.6] (0,6) circle (2cm and 0.5cm);
\draw (-2,6) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,6) ++ (-2,0) circle (2cm and 0.5cm);
\draw[densely dashed] (-2,0) arc (180:0:2cm and 0.5cm);
\draw  (-2,4) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,4) ++ (-2,0) circle (2cm and 0.5cm);
\draw [densely dashed, thick] (-2,4) arc (180:0:2cm and 0.5cm);
\end{tikzpicture}

enter image description here

I managed to draw the cylinder and play around with it (color it etc) plus a circle somewhere in the cylinder but I cannot the plane z=4 in order to capture the extra circle I made. I would like also to draw to plane with the color gray!20!. I followed some codes I found but some of them do not compile and others simply "do not do their job".

I also tried it manually but I'm having problem finding the correct coordinates. Any help?

1
  • Your ellipses have an aspect ration of 4/1, so just draw a parallelogram with the same center and the same aspect ratio (height vs width, not sides). Jun 7, 2015 at 0:02

1 Answer 1

3

Okay, it was slightly more complicated than I first thought.

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\fill[top color=blue!50!,bottom color=blue!20! ,middle  color=red!20!,shading=axis,opacity=0.6] (0,0) circle (2cm and 0.5cm);
\fill[left color=blue!50!,right color=blue!20! ,middle color=red!20! ,shading=axis,opacity=0.6] (2,0) -- (2,6) arc (360:180:2cm and 0.5cm) -- (-2,0) arc (180:360:2cm and 0.5cm);
\fill[top color=blue!50!,bottom color=blue!20,middle color=red!20! ,shading=axis,opacity=0.6] (0,6) circle (2cm and 0.5cm);
\draw (-2,6) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,6) ++ (-2,0) circle (2cm and 0.5cm);
\draw[densely dashed] (-2,0) arc (180:0:2cm and 0.5cm);
\draw  (-2,4) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,4) ++ (-2,0) circle (2cm and 0.5cm);
\draw [densely dashed, thick] (-2,4) arc (180:0:2cm and 0.5cm);
\draw (-2,5) -- (-3,5) --(-5,3) -- (3,3) -- (5,5) -- (2,5);
\draw[dashed] (-2,5) -- (2,5);
\fill[green,opacity=0.5] 
 (-2,4) -- (-2,5) -- (-3,5) -- (-5,3) -- (3,3) -- (5,5) -- (2,5) -- (2,4) arc (0:180:2cm and -0.5cm);
\end{tikzpicture}
\end{document}

cylendar

1
  • Thank you for the tip in your first comment (I had not noticed that) and for the nice shape you provided here in your answer.
    – Tolaso
    Jun 7, 2015 at 2:01

You must log in to answer this question.

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