Edit and compile if you like:
\documentclass{article} % % File name: cylinder-truncated-by-plane.tex % Description: % A solid bounded by the following surfaces % z = 0 % x^{2} + y^{2} = 4 % x + y + z = 4 % is generated. I.e., the intersection of a cylinder with a plane % for z >= 0. % % Date of creation: April, 23rd, 2022. % Date of last modification: April, 23rd, 2022. % Author: Efraín Soto Apolinar. % https://www.aprendematematicas.org.mx/author/efrain-soto-apolinar/instructing-courses/ % Terms of use: % According to TikZ.net % https://creativecommons.org/licenses/by-nc-sa/4.0/ % \usepackage{tikz} \usetikzlibrary{patterns} \usepackage{tikz-3dplot} \usetikzlibrary{math} \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{1pt} % \begin{document} % \tdplotsetmaincoords{60}{110} \begin{tikzpicture}[tdplot_main_coords,scale=0.65] \tikzmath{function a(\x,\y) {return (4.0-\x-\y);};} \pgfmathsetmacro{\final}{2.0*pi} \pgfmathsetmacro{\ejez}{a(0,0)} % The equation of the cyrcumference \draw[white] (0,-2.5,0) -- (2.75,0,0) node[blue,midway,below,sloped] {\footnotesize$x^2 + y^2 = 4$}; % The region of integration: the circle of radius 2 \draw[thick,fill=yellow,opacity=0.5] plot[domain=0:6.2832,smooth,variable=\t] ({2.0*cos(\t r)},{2.0*sin(\t r)},{0.0}); %%% Coordinate axis \draw[thick,->] (0,0,0) -- (3.5,0,0) node [below left] {\footnotesize$x$}; \draw[dashed] (0,0,0) -- (-3,0,0); \draw[thick,->] (0,0,0) -- (0,3.5,0) node [right] {\footnotesize$y$}; \draw[dashed] (0,0,0) -- (0,-3,0); \draw[thick] (0,0,0) -- (0,0,\ejez);% node [above] {\footnotesize$z$}; % The plane: x + y + z = 4 \pgfmathsetmacro{\Az}{a(2.5,2.5)} \pgfmathsetmacro{\Bz}{a(-2.5,2.5)} \pgfmathsetmacro{\Cz}{a(-2.5,-2.5)} \pgfmathsetmacro{\Dz}{a(2.5,-2.5)} \coordinate (A) at (2.5,2.5,\Az); \coordinate (B) at (-2.5,2.5,\Bz); \coordinate (C) at (-2.5,-2.5,\Cz); \coordinate (D) at (2.5,-2.5,\Dz); % The cylinder \foreach \angulo in {0,0.01,...,\final}{ \pgfmathparse{2.0*cos(\angulo r)} \pgfmathsetmacro{\px}{\pgfmathresult} \pgfmathparse{2.0*sin(\angulo r)} \pgfmathsetmacro{\py}{\pgfmathresult} \draw[cyan,opacity=0.5] (\px,\py,0) -- (\px,\py,4.0-\px-\py); } % The intersection of the cylinder and the plane (the trace) \draw[blue,thick] plot[domain=0:6.2832,smooth,variable=\t] ({2.0*cos(\t r)},{2.0*sin(\t r)},{4.0-2.0*sin(\t r)-2.0*cos(\t r)}); % Circumference & Ellipse bounding the solid. \draw[blue,thick,opacity=0.5] plot[domain=0:6.2831853,smooth,variable=\t] ({2.0*cos(\t r)},{2.0*sin(\t r)},{4.0-2*sin(\t r)-2.0*cos(\t r)}); \draw[blue,thick,opacity=0.5] plot[domain=0:6.2831853,smooth,variable=\t] ({2.0*cos(\t r)},{2.0*sin(\t r)},{0.0}); % The plane \draw[white] (C) -- (B) node[red,above,sloped,midway]{\footnotesize$x + y + z = 4$}; \draw[red,dash dot] (A) -- (B) -- (C) -- (D) -- (A); \fill[pattern color=pink,pattern=north east lines] (A) -- (B) -- (C) -- (D) -- (A); \fill[pink,opacity=0.5] plot[domain=0:6.2832,smooth,variable=\t] ({2.0*cos(\t r)},{2.0*sin(\t r)},{4.0-2.0*sin(\t r) - 2.0*cos(\t r)}); % z axis (last part) \draw[thick,->] (0,0,\ejez) -- (0,0,8) node [above] {\footnotesize$z$}; \end{tikzpicture} \end{document}
Click to download: cylinder-truncated-by-plane.tex • cylinder-truncated-by-plane.pdf
Open in Overleaf: cylinder-truncated-by-plane.tex
See more on the author page of Efraín Soto Apolinar.