Truncated Cylinder

truncated-cylinder

Edit and compile if you like:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{math}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{1pt}
%
% File name: truncated-cylinder.tex
% Description: 
% A geometric representation of a truncated cylinder is shown.
% 
% Date of creation: April, 9th, 2021.
% Date of last modification: October, 9th, 2022.
% Author: Efran Soto Apolinar.
% https://www.aprendematematicas.org.mx/author/efrain-soto-apolinar/instructing-courses/
% Source: page 44 of the 
% Glosario Ilustrado de Matem\'aticas Escolares.
% https://tinyurl.com/5udm2ufy
%
% Terms of use:
% According to TikZ.net
% https://creativecommons.org/licenses/by-nc-sa/4.0/
% Your commitment to the terms of use is greatly appreciated.
%
\begin{document}
	%
	\tdplotsetmaincoords{70}{100}
	%
	\begin{tikzpicture}[tdplot_main_coords]
		\pgfmathsetmacro{\r}{2}
		% Base of the truncated cylinder
		\draw[thick,fill=cyan!35,opacity=0.75] plot[domain=0:6.2832,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{0.0});
		\draw[red,thick,dashed] plot[domain=1.570796327:4.71238898,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{0.0}); 
		% Vertical wall (back, external radius)
		\fill[gray!35,opacity=0.5] (0,\r,0) 
			-- plot[domain=1.571:4.71238898,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{0})
			-- (0,-\r,4) 
			-- plot[domain=4.71238898:1.571,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{4.0-\r*sin(\t r)})
			-- (0,\r,0);	
		% Vertical wall (front, external radius)
		\fill[cyan!35,opacity=0.5] (0,-\r,0) 
			-- plot[domain=-1.571:1.571,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{0}) 
			-- (0,\r,2.0) 
			-- plot[domain=1.571:-1.571,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{4.0-\r*sin(\t r)}) 
			-- (0,-\r,0);
		% section of the plane (cut by a plane)
		\draw[thick] plot[domain=0:6.2832,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{4.0-\r*sin(\t r)});
		% The cylinder (vertical wall
		\foreach \angulo in {0,0.05,...,6.3}{
				\pgfmathparse{2.0*cos(\angulo r)}
				\pgfmathsetmacro{\px}{\pgfmathresult}
				\pgfmathparse{2.0*sin(\angulo r)}
				\pgfmathsetmacro{\py}{\pgfmathresult}
				\draw[cyan] (\px,\py,0) -- (\px,\py,4.0-\py);
			}
		\fill[cyan!35,opacity=0.75] plot[domain=0:6.2832,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{4.0-\r*sin(\t r)});
		% Circumferences bounding the cylinder
		\draw[red,thick] plot[domain=0:6.2831853,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{4.0-\r*sin(\t r)}); 
		\draw[red,thick] plot[domain=-1.570796327:1.570796327,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{0.0}); 
		% lengths and indication of points
		\draw[dash dot dot] (0,0,-1) -- (0,0,6);
		\draw[dash dot dot] (0,-\r,6) -- (0,\r,2);
		\draw[dash dot dot] (-\r,0,4) -- (\r,0,4);
		\draw[dash dot dot] (0,0,4) -- (0,\r+1.5,4);
		\draw[dash dot dot] (-\r,0,0) -- (\r,0,0);
		\draw[dash dot dot] (0,-\r-1.0,0) -- (0,\r+1.5,0);
		\draw[dash dot dot] (0,-\r-1.0,6) -- (0,-\r,6);
		\draw[dash dot dot] (0,\r,5.5) -- (0,\r,2) -- (0,\r+1,2);
		\draw[thick,<->] (0,0,5) -- (0,\r,5) node [midway,fill=white] {$r$};
		\draw[thick,<->] (0,\r+0.5,0) -- (0,\r+0.5,2) node [midway,fill=white] {$h_{1}$};
		\draw[thick,<->] (0,-\r-0.5,0) -- (0,-\r-0.5,6) node [midway,fill=white] {$h_{2}$};
		\draw[thick,<->] (0,\r+1.0,0) -- (0,\r+1.0,4) node [midway,fill=white] {$h$};
	\end{tikzpicture}
	%
\end{document}

Click to download: truncated-cylinder.textruncated-cylinder.pdf
Open in Overleaf:
truncated-cylinder.tex
See more on the author page of Efraín Soto Apolinar.

Leave a Reply

Your email address will not be published.