general-cylinder

Edit and compile if you like:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{math}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{0.125pt}
%
% File name: general-cylinder.tex
% Description: 
% A geometric representation of a general cylinder is shown.
% 
% Date of creation: March, 7th, 2021.
% Date of last modification: October, 9th, 2022.
% Author: Efraín 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{60}{140}
	%
	\begin{tikzpicture}[tdplot_main_coords]
		\pgfmathsetmacro{\h}{3}
		\pgfmathsetmacro{\a}{3}
		\pgfmathsetmacro{\f}{1.0}
		\pgfmathsetmacro{\xi}{0.0}
		\pgfmathsetmacro{\xf}{2.0*pi}
		\pgfmathsetmacro{\step}{0.0025*(\xf-\xi)}
		\pgfmathsetmacro{\xs}{\xi+\step}
		\pgfmathsetmacro{\xa}{\xf-\step}
		% Coordinate axis
		\draw[thick,->] (-0.25,0,0) -- (\xf+0.5,0,0) node [below] {$x$};
		\draw[thick,->] (0,-0.25,0) -- (0,1.5,0) node [right] {$y$};
		\draw[thick,->] (0,0,-0.25) -- (0,0,\h+0.5) node [above] {$z$};
		% The edge of the cylinder
		\draw[red,thick] plot[domain=\xi:\xf,smooth,variable=\t] ({\t},{sin(\t r)},{0.0});
		\draw[red,thick] (0,0,0) -- (0,0,\h);
		% A sinusoidal cylinder
		\foreach \x in {\xi,\xs,...,\xf}{
			\pgfmathsetmacro{\px}{sin(\x r)}
			\draw[cyan,opacity=0.5] (\x,\px,0.0) -- (\x,\px,\h);
		}
		% Upper part of the edge
		\draw[red,thick] plot[domain=\xi:\xf,smooth,variable=\t] ({\t},{sin(\t r)},{\h});
		\draw[red,thick] (\xf,0,0) -- (\xf,0,\h);
	\end{tikzpicture}
	%
\end{document}

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

Leave a Reply

Your email address will not be published.