Draw L-Shaped Half Cylinder

tikz-pgf

I have been trying to draw this but unable to color it or create the grids.. can anyone help me?

solid

This is my MWE:

\documentclass[tikz]{standalone}

\begin{document}
    \begin{tikzpicture}
        % Arc
        \draw(0.66,1.26) arc (37:90:0.8 and 1.8);% left arc
        \draw(3.3,1.3) arc (37:90:-0.8 and 1.8);% left arc
        
        % Lines
        \draw (2,3) -- (0,2);% line 1
        \draw (2,3) -- (4,2);% line 2
        \draw (2,2) -- (0.66,1.3);% line 3
        \draw (2,2) -- (3.3,1.3);% line 4
        \draw (0,2) -- (0,1.4);% line 5
        \draw (0,1.4) -- (0.66,1.3);% line 6
        \draw (4,2) -- (4,1.5);% line 7
        \draw (4,1.5) -- (3.3,1.3);% line 8
            
        \draw (-1.25,1.5) node {$\phi$};
        
    \end{tikzpicture}
\end{document}

Best Answer

For this I'd recommend you perspective and 3d TikZ libraries. The latter allows to change the coordinate system to a 2d one situated in a plane parallel to the axes with the options (for example)

[canvas is xy plane at z=2]

In the above example we are changing the reference system to a new one situated in a plane parallel to xy plane at height z=2.

That said, it will be necessary to parametrize the intersection curve of both cylinders. They intersect at the plane y=x, so one possibility is

(sin(t), sin(t), cos(t)), t∈[0,90]

Last, actually answering your question, the grids can be generated with a \foreach loop.

A complete example could be:

% https://tex.stackexchange.com/questions/670532/draw-l-shaped-half-cylinder
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{3d,perspective}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,3d view={120}{30}]
% Axes
\draw[-latex] (0,0,0) -- (4,0,0) node[below] {$x$};
\draw[-latex] (0,0,0) -- (0,4,0) node[below] {$y$};
\draw[-latex] (0,0,0) -- (0,0,2) node[above] {$z$};
% Inside
\draw[fill=blue!50,canvas is xy plane at z=0] (3,0) |- (1,1) |- (0,3) |- cycle;
\draw[fill=blue!30,canvas is xz plane at y=0] (0,0) rectangle (3,1);
\draw[fill=blue!35,canvas is yz plane at x=0] (0,0) rectangle (3,1);
% Outside
\draw[top color=blue!50] {[canvas is yz plane at x=3] (1,0) arc (0:90:1)} -- (0,0,1)  --
                     plot [domain=0:90,samples=21]    ({sin(\x)},{sin(\x)},{cos(\x)}) -- cycle;
\draw[top color=blue!60] {[canvas is xz plane at y=3] (1,0) arc (0:90:1)} -- (0,0,1)  --
                     plot [domain=0:90,samples=21]    ({sin(\x)},{sin(\x)},{cos(\x)}) -- cycle;
% Grids
\foreach\i in {10,20,...,80}
  \draw[opacity=0.2] (3,{cos(\i)},{sin(\i)}) -- ({cos(\i)},{cos(\i)},{sin(\i)}) -- ({cos(\i)},3,{sin(\i)});
\foreach\i in {0.2,0.4,...,2.8}
{
  \pgfmathsetmacro\minangle{acos(min(1,\i))}
  \draw[canvas is yz plane at x=\i,opacity=0.2] (0,1) arc (90:\minangle:1);
  \draw[canvas is xz plane at y=\i,opacity=0.2] (0,1) arc (90:\minangle:1);
}  
\end{tikzpicture}
\end{document}

enter image description here