[Tex/LaTex] Drawing cylinders using tikzpicture

tikz-pgf

How do you draw the following cylinders in latex using tikzpicture?

What I want to achieve

I have managed to learn how to draw rectangles, triangle and cuboid so far. However I have never drawn that involves circular sides.

Thank you.

Best Answer

Please include code showing what you've tried. There are also a lot of questions on this site about drawing cylinders, as well as examples in the TikZ manual.

For example, a few moments looking at the shapes.geometric library suggests something like this:

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
  \node (a) [cylinder, shape border rotate=90, draw, minimum height=15mm, minimum width=7.5mm] {};
  \draw [<->] ([xshift=5pt]a.before bottom) -- ([xshift=5pt]a.after top) node [midway, right] {$h$};
  \draw [<->] ([yshift=-5pt]a.bottom) -- ([yshift=-5pt]a.bottom -| a.before bottom) node [midway, below] {$r$};
\end{tikzpicture}
\end{document}

cylinder