# Drawing a cut cylinder with Tikz

I'm trying to use tikz to create the attached image, but I'm not sure this is possible. I know I can use the package to draw cylinders, as shown here and here. But I don't think I can use the \usetikzlibrary{shapes} to provide the cut shown in the attachment. Is this at all feasible with tikz?

This draws such a cylinder and also uses patterns.meta for the ellipses.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{patterns.meta,decorations.pathmorphing}
\begin{document}
\def\pk#1{\pgfkeysvalueof{/pgf/pattern keys/#1}}
\tikzdeclarepattern{name=lines,
parameters={
\pk{size},
\pk{angle},
\pk{line width},
\pk{gap},
},
bounding box={(-.1pt,-.1pt) and
(\pk{size}+.1pt,
{\pk{gap}+.1pt})},
tile size={(\pk{size},
{\pk{gap}})},
tile transformation={rotate=\pk{angle}},
defaults={
size/.initial=5pt,
angle/.initial=0,
line width/.initial=.4pt,
gap/.initial=3pt
}, code={
\draw[line width=\pk{line width}]
(0,0) -- ({\pk{size}},0) ;
} }
\begin{tikzpicture}[pics/fcylinder/.style={code={
\tikzset{fcylinder/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/fcylinder/##1}}
\draw[fill=gray!30] (0,\pv{r})
-- (\pv{h},-\pv{r}) to[out=180,in=-120]
(\pv{h},0) to[out=60,in=0] (\pv{h},\pv{r}) -- cycle;
\draw[fill=gray!60]  (\pv{h},-\pv{r}) to[out=180,in=-120]  (\pv{h},0)
to[out=-60,in=0] cycle;
\draw[fcylinder/finish] (0,\pv{r})
}},fcylinder/.cd,r/.initial=5mm,h/.initial=1cm,aspect/.initial=1/3,
finish/.style={solid}]
\begin{scope}[local bounding box=Dirichlet]
\path[pattern={lines[line width=.8pt,angle=30]}]
\path (0,0) pic{fcylinder={finish/.style=dashed}};
\end{scope}
%
\begin{scope}[xshift=3.5cm,local bounding box=Neumann]
\path (0,0) pic{fcylinder};
\draw[very thick,-stealth] (0,0) -- node[above] {$\bar N$}++ (-1,0);
\end{scope}
%
\begin{scope}[xshift=7cm,local bounding box=Robin]
\path[pattern={lines[line width=.8pt,angle=30]}]
\path (1,0) pic{fcylinder};
\draw[thick,decorate,decoration={zigzag,segment length=1.5mm,amplitude=2mm,
pre length=2mm,post length=2mm}] (0,0) -- (1,0);
\end{scope}
%
\end{tikzpicture}
\end{document}


• Fantastic, how did you come up with that parametrization for the cylinder? – N3buchadnezzar Jan 28 at 13:52
• @N3buchadnezzar Just guessing. (Surprisingly the first thing I tried looked reasonable so I took it.) – Schrödinger's cat Jan 28 at 14:05