# Differential of Volume Cylindrical Coordinates

Edit and compile if you like:

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{tikz-3dplot}
\usetikzlibrary{math}
\usepackage{ifthen}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{1pt}
%
% File name: differential-of-volume-cylindrical-coordinates.tex
% Description:
% A geometric representation of the differential of volume
% in cylindrical coordinates is shown.
%
% 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 121 of the
% Glosario Ilustrado de Matem\'aticas Escolares.
% https://tinyurl.com/5udm2ufy
%
% According to TikZ.net
%
\begin{document}
%
\begin{center}
\tdplotsetmaincoords{70}{120}
%
\begin{tikzpicture}[tdplot_main_coords,scale=1.5]
% Coordinates of the location of the differential of volume
\pgfmathsetmacro{\x}{1}
\pgfmathsetmacro{\y}{1.5}
\pgfmathsetmacro{\z}{1.5}
% compute the coordinates in cylindrical coordinates
\pgfmathsetmacro{\angulo}{atan(\y/\x)}
\pgfmathsetmacro{\dominio}{\angulo*pi/180}
% For the differential
\pgfmathsetmacro{\dangulo}{8}
\pgfmathsetmacro{\dz}{0.35}
\pgfmathsetmacro{\dominiof}{(\angulo+\dangulo)*pi/180}
% Coordinates of the vertices of the differential of volume
% \z = \z, it does not require conversion
% Location of the node
\pgfmathsetmacro{\xnodo}{0.35*cos(0.5*\angulo)}
\pgfmathsetmacro{\ynodo}{0.35*sin(0.5*\angulo)}
%
\pgfmathsetmacro{\angulof}{\angulo+\dangulo}
\pgfmathsetmacro{\zf}{\z+\dz}
% Coordinate axis
\draw[thick,->] (0,0,0) -- (\radiof+0.5,0,0) node [below left] {$x$};
\draw[thick,->] (0,0,0) -- (0,\radiof+0.5,0) node [right] {$y$};
\draw[thick,->] (0,0,0) -- (0,0,\zf+0.5) node [above] {$z$};
% The origin
\coordinate (O) at (0,0,0);
% Differential of area in polar coordinates (in the xy plane)
% Differential of $\theta$
\draw[blue,dashed](0,0,0) --  (\xfrayouno,\yfrayouno,0) node[below left] {$\theta$};
\draw[blue,dashed](0,0,0) --  (\xfrayodos,\yfrayodos,0) node [below right] {$\theta + d\theta$};
% Differential of $r$ ($dr$)
% Differential of area
\draw[blue] (\Ax,\Ay,0) -- (\Bx,\By,0)
-- (\Dx,\Dy,0)
-- (\Ax,\Ay,0);
\node[blue,above left] at (\radio,0,0) {$r$};
\node[blue,above left] at (\radiof,0,0) {$r + dr$};
% Auxiliary lines
\draw[blue,dashed] (\x,\y,\z) -- (0,0,\z) node [left] {$z$};
\draw[blue,dashed] (0,0,\z) -- (\Dx,\Dy,\z);
\draw[blue,dashed] (\x,\y,\zf) -- (0,0,\zf) node [left] {$z + dz$};
\draw[blue,dashed] (0,0,\zf) -- (\Dx,\Dy,\zf);
%
\draw[blue,dashed] (\x,\y,0) -- (\x,\y,\z);
\draw[blue,dashed] (\Bx,\By,0) -- (\Bx,\By,\z);
\draw[blue,dashed] (\Cx,\Cy,0) -- (\Cx,\Cy,\z);
\draw[blue,dashed] (\Dx,\Dy,0) -- (\Dx,\Dy,\z);
%
\draw[blue] plot[domain=0:\dominio,smooth,variable=\t] ({0.5*cos(\t r)},{0.5*sin(\t r)});  % 0.5236
\node[blue,below] at (\xnodo,\ynodo,0) {$\theta$};
\node[below left] at (\Ax,\Ay,\z) {$dV = r\cdot dz \cdot dr \cdot d\theta$};
% Differential of volume in cylindrical coordinates:
% vertical edges
\draw[red,thick] (\Dx,\Dy,\z) -- (\Dx,\Dy,\zf);
% filling in yellow to give the sensation of a solid
% frontal face
\fill[cyan,opacity=0.75] (\Ax,\Ay,\z) -- (\Bx,\By,\z) -- (\Bx,\By,\zf) -- (\Ax,\Ay,\zf) -- (\Ax,\Ay,\z);
% top face
\fill[cyan,opacity=0.75] (\Ax,\Ay,\zf) -- (\Bx,\By,\zf)
-- (\Dx,\Dy,\zf)
-- (\Ax,\Ay,\zf);
% face at r + dr
\fill[cyan,opacity=0.75] (\Bx,\By,\z)
-- (\Cx,\Cy,\zf)
-- (\Bx,\By,\z);

% The differential of area at height $z$
\draw[red,thick] (\Ax,\Ay,\z) -- (\Bx,\By,\z)
-- (\Dx,\Dy,\z)
-- (\Ax,\Ay,\z);
% The differential of area at height  $z + dz$
\draw[red,thick] (\Ax,\Ay,\zf) -- (\Bx,\By,\zf)
-- (\Dx,\Dy,\zf)
-- (\Ax,\Ay,\zf);
% Vertical edges of the differential of volume
\draw[red,thick] (\Ax,\Ay,\z) -- (\Ax,\Ay,\zf);
\draw[red,thick] (\Bx,\By,\z) -- (\Bx,\By,\zf);
\draw[red,thick] (\Cx,\Cy,\z) -- (\Cx,\Cy,\zf);

\end{tikzpicture}
\end{center}
%
\end{document}