# Draw U shaped pipe in 3d

How to draw a U-shaped pipe like this in tikz? Here is what I tried so far, very rudimentary:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\pgfmathsetmacro{\rI}{0.7}

%Height
\pgfmathsetmacro{\h}{7}

%Diameter of the pipe
\pgfmathsetmacro{\d}{1}

\pgfmathsetmacro{\rO}{\rI + \d}

\pgfmathsetmacro{\s}{2}

%%Inner Part
\draw (0,0) -- (0,-\h) coordinate (I1);
\draw[shift=(I1),xshift=\rI cm] plot[domain=270:90] ({\rI*sin(\x)},{\rI*cos(\x)}) coordinate (I2);
\draw (I2) -- ++(0,\h);

%% Outer Part
\draw (-\d,0) -- ++(0,-\h) coordinate (O1);
\draw[shift=(O1),xshift=\rO cm] plot[domain=270:90] ({\rO*sin(\x)},{\rO*cos(\x)}) coordinate (O2);
\draw (O2) -- ++(0,\h);

%% l Line
\draw (-\d/2.0,-0.5*\h+\s) -- ++(0,-0.5*\h-\s) coordinate (L1);
\pgfmathsetmacro{\rl}{\rO - 0.5*\d}
\draw[shift=(L1),xshift=\rl cm] plot[domain=270:90] ({\rl*sin(\x)},{\rl*cos(\x)}) node[below=1.2cm,pos=0.5]{$l$} coordinate (L2);
\draw (L2) -- ++(0,0.5*\h-\s);

\draw[->] (-3,-\h-\rO) -- (-3,0) node[left]{\small Ort $y$};
\draw (-3.1,-0.5*\h) node[left]{$0$} -- ++(0.2,0);
\end{tikzpicture}

\end{document}


Output: I don't see how to color it, and how to make it look 3d (I guess 3d could be even better than in my original posted picture, since there the bottom of the pipe looks 2d). Also my approach seems not to be very elegant.

• 12th question and "Do it for me": I recommend to show more effort and at least provide an MWE (tex.meta.stackexchange.com/questions/228). Sep 7, 2017 at 9:38
• Google cylinders tikz: tex.stackexchange.com/questions/277065 (maybe related) Sep 7, 2017 at 9:41
• @Dr.ManuelKuehner... and there are users upvoting the questions anyway ;-)
– user31729
Sep 7, 2017 at 9:57
• @ChristianHupfer I have my own theory :) Sep 7, 2017 at 9:59
• @Dr.ManuelKuehner: I included what I tried so far. Sep 7, 2017 at 10:04

You already did all the hard work. To add the blue fill colour you could simply draw the line you already have a second time with a bigger width. To add the ellipses you could do \draw (-\d/2.0,-0.5*\h+\s) ellipse (0.5 and 0.1);

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\pgfmathsetmacro{\rI}{0.7}

%Height
\pgfmathsetmacro{\h}{7}

%Diameter of the pipe
\pgfmathsetmacro{\d}{1}

\pgfmathsetmacro{\rO}{\rI + \d}

\pgfmathsetmacro{\s}{2}

%%Inner Part
\draw (0,0) -- (0,-\h) coordinate (I1);
\draw[shift=(I1),xshift=\rI cm] plot[domain=270:90] ({\rI*sin(\x)},{\rI*cos(\x)}) coordinate (I2);
\draw (I2) -- ++(0,\h);

%% Outer Part
\draw (-\d,0) -- ++(0,-\h) coordinate (O1);
\draw[shift=(O1),xshift=\rO cm] plot[domain=270:90] ({\rO*sin(\x)},{\rO*cos(\x)}) coordinate (O2);
\draw (O2) -- ++(0,\h);

% NEW
\draw[blue!20!white, line width=28pt] (-\d/2.0,-0.5*\h+\s) -- ++(0,-0.5*\h-\s) coordinate (L1);
\draw[fill=blue!40!white] (-\d/2.0,-0.5*\h+\s) ellipse (0.5 and 0.1);

%% l Line
\draw (-\d/2.0,-0.5*\h+\s) -- ++(0,-0.5*\h-\s) coordinate (L1);
\pgfmathsetmacro{\rl}{\rO - 0.5*\d}
\draw[shift=(L1),xshift=\rl cm] plot[domain=270:90] ({\rl*sin(\x)},{\rl*cos(\x)}) node[below=1.2cm,pos=0.5]{$l$} coordinate (L2);
\draw (L2) -- ++(0,0.5*\h-\s);

\draw[->] (-3,-\h-\rO) -- (-3,0) node[left]{\small Ort $y$};
\draw (-3.1,-0.5*\h) node[left]{$0$} -- ++(0.2,0);
\end{tikzpicture}

\end{document} 