I have found a workaround to this problem by using multiple cylindrical surfaces (2 surfaces in order to simplify the problem) whose area changes according to the rotation about an axis in such a way that you still see the half cylinder. I had to use a separate macro that I created, \zr
which adjusts the start angles and end angles of the arcs accordingly. The \zr
macro defines the angle of rotation about the z-axis for this particular problem.
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\pgfmathsetmacro{\zr}{0} % Value of rotation angle about z-axis
\begin{tikzpicture}[x={(1cm,0cm)},y={(0cm,-0.5cm)},z={(0cm,1cm)},rotate around z=\zr]
\draw[-stealth] (0,0,0) -- (8,0,0) node[right]{$x$};
\draw[-stealth] (0,0,0) -- (0,8,0) node[below]{$y$};
\draw[-stealth] (0,0,0) -- (0,0,8) node[above]{$z$};
\draw[fill=gray!10,opacity=0.5] (0,0,0) circle [radius=1];
\draw[preaction={fill=gray,nearly transparent}] (0:1) arc[start angle=0,end angle=180-\zr,radius=1] --++ (0,0,3) arc[start angle=180-\zr,end angle=0,radius=1] -- cycle;
\draw[preaction={fill=gray,nearly transparent}] (0:-1) arc[start angle=180,end angle=180-\zr,radius=1] --++ (0,0,3) arc[start angle=180-\zr,end angle=180,radius=1] -- cycle;
\end{tikzpicture}
\end{document}
The output for various values of \zr
:
UPDATE
And now for full cylinder rotation about z-axis:
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\pgfmathsetmacro{\zr}{0} % Value of rotation angle about z-axis
\begin{tikzpicture}[x={(1cm,0cm)},y={(0cm,-0.5cm)},z={(0cm,1cm)},rotate around z=\zr]
\draw[-stealth] (0,0,0) -- (2,0,0) node[right]{$x$};
\draw[-stealth] (0,0,0) -- (0,2,0) node[below]{$y$};
\draw (0,0,0) circle [radius=1];
\fill[gray] (0:1) arc[start angle=0,end angle=180-\zr,radius=1] --++ (0,0,3) arc[start angle=180-\zr,end angle=0,radius=1] --cycle;
\fill[gray] (0:-1) arc[start angle=180,end angle=180-\zr,radius=1] --++ (0,0,3) arc[start angle=180-\zr,end angle=180,radius=1] --cycle;
\fill[gray] (0:-1) arc[start angle=180,end angle=360-\zr,radius=1] --++ (0,0,3) arc[start angle=360-\zr,end angle=180,radius=1] --cycle;
\fill[gray] (0:1) arc[start angle=0,end angle=0-\zr,radius=1] --++ (0,0,3) arc[start angle=0-\zr,end angle=0,radius=1] --cycle;
\draw[very thin] {[canvas is xy plane at z=0] (-\zr:1)}{[canvas is xy plane at z=3] -- (-\zr:1)};
\draw[very thin] {[canvas is xy plane at z=0] (180-\zr:1)}{[canvas is xy plane at z=3] -- (180-\zr:1)};
\draw[fill=gray!10,opacity=0.5] (0,0,3) circle [radius=1];
\draw (0,0,3) --++ (\zr:1);
\draw[-stealth] (0,0,3) -- (0,0,4) node[above]{$z$};
\end{tikzpicture}
\end{document}
The output of full rotation of cylinder about z-axis:
And now for the final part, which involves setting values for \zr
and another macro \phi
that I named to represent the rotation of the second arm of the Furuta Pendulum.
The complete code:
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\pgfmathsetmacro{\zr}{45} % Value of rotation angle about z-axis
\pgfmathsetmacro{\phi}{0} % Joint rotation angle
\begin{tikzpicture}[x={(1cm,0cm)},y={(0cm,-0.5cm)},z={(0cm,1cm)}]
\draw[-stealth] (0,0,0) -- (3,0,0) node[right]{$x$};
\draw[-stealth,y={(0.707cm,0.707cm)}] (0,0,0) -- (0,2,0) node[below]{$y$};
% Base of the Furuta Pendulum (DC Motor?)
\draw (0,0,0) circle [radius=1];
\fill[gray] (0:1) arc[start angle=0,end angle=180-\zr,radius=1] --++ (0,0,3) arc[start angle=180-\zr,end angle=0,radius=1] --cycle;
\fill[gray] (0:-1) arc[start angle=180,end angle=180-\zr,radius=1] --++ (0,0,3) arc[start angle=180-\zr,end angle=180,radius=1] --cycle;
\fill[gray] (0:-1) arc[start angle=180,end angle=360-\zr,radius=1] --++ (0,0,3) arc[start angle=360-\zr,end angle=180,radius=1] --cycle;
\fill[gray] (0:1) arc[start angle=0,end angle=0-\zr,radius=1] --++ (0,0,3) arc[start angle=0-\zr,end angle=0,radius=1] --cycle;
\draw[very thin] {[canvas is xy plane at z=0] (0:1)}{[canvas is xy plane at z=3] -- (0:1)};
\draw[very thin] {[canvas is xy plane at z=0] (180:1)}{[canvas is xy plane at z=3] -- (180:1)};
\draw[fill=gray!10] (0,0,3) circle [radius=1];
\begin{scope}[rotate around z=\zr]
% Motor Driver
\draw (0,0,3) circle [radius=0.75];
\fill[gray!80]{[canvas is xy plane at z=3] (0:0.75) arc[start angle=0,end angle=180-\zr,radius=0.75]}{[canvas is xy plane at z=3.5] --++ (0,0,0) arc[start angle=180-\zr,end angle=0,radius=0.75]} --cycle;
\fill[gray!80]{[canvas is xy plane at z=3] (0:-0.75) arc[start angle=180,end angle=180-\zr,radius=0.75]}{[canvas is xy plane at z=3.5] --++ (0,0,0) arc[start angle=180-\zr,end angle=180,radius=0.75]} --cycle;
\fill[gray!80]{[canvas is xy plane at z=3] (0:-0.75) arc[start angle=180,end angle=360-\zr,radius=0.75]}{[canvas is xy plane at z=3.5] --++ (0,0,0) arc[start angle=360-\zr,end angle=180,radius=0.75]} --cycle;
\fill[gray!80]{[canvas is xy plane at z=3] (0:0.75) arc[start angle=0,end angle=0-\zr,radius=0.75]}{[canvas is xy plane at z=3.5] --++ (0,0,0) arc[start angle=0-\zr,end angle=0,radius=0.75]} --cycle;
\draw[very thin] {[canvas is xy plane at z=3] (-\zr:0.75)}{[canvas is xy plane at z=3.5] -- (-\zr:0.75)};
\draw[very thin] {[canvas is xy plane at z=3] (180-\zr:0.75)}{[canvas is xy plane at z=3.5] -- (180-\zr:0.75)};
\draw[fill=gray!10] (0,0,3.5) circle [radius=0.75];
\draw[-stealth] (0,0,3.5) -- (0,0,6) node[above]{$z$};
% First Arm
\draw[fill=gray!10]{[canvas is yz plane at x=0.75] (0,3.25,0) circle [radius=0.1]};
\fill[gray!60]{[canvas is yz plane at x=0.75] (0,3.25,0) ++ (\zr:0.1) coordinate (a) arc[start angle=\zr,end angle=\zr+90,radius=0.1]}{[canvas is yz plane at x=3.25] --++ (0,0,0) arc[start angle=\zr+90,end angle=\zr,radius=0.1]} --cycle;
\fill[gray!60]{[canvas is yz plane at x=0.75] (0,3.25,0) ++ (\zr+90:0.1) coordinate (a) arc[start angle=\zr+90,end angle=\zr+180,radius=0.1]}{[canvas is yz plane at x=3.25] --++ (0,0,0) arc[start angle=\zr+180,end angle=\zr+90,radius=0.1]} --cycle;
\fill[gray!60]{[canvas is yz plane at x=0.75] (0,3.25,0) ++ (\zr+180:0.1) coordinate (b) arc[start angle=\zr+180,end angle=\zr+270,radius=0.1]}{[canvas is yz plane at x=3.25] --++ (0,0,0) arc[start angle=\zr+270,end angle=\zr+180,radius=0.1]} --cycle;
\fill[gray!60]{[canvas is yz plane at x=0.75] (0,3.25,0) ++ (\zr+270:0.1) coordinate (b) arc[start angle=\zr+270,end angle=\zr+360,radius=0.1]}{[canvas is yz plane at x=3.25] --++ (0,0,0) arc[start angle=\zr+360,end angle=\zr+270,radius=0.1]} --cycle;
\draw[fill=gray!10]{[canvas is yz plane at x=2.75] (0,3.25,0) circle [radius=0.1]};
% Joint
\begin{scope}
\draw[fill=gray!10]{[canvas is yz plane at x=2.75] (0,3.25,0) circle [radius=0.3]};
\fill[gray!40]{[canvas is yz plane at x=2.75] (0,3.25,0) ++ (\zr:0.3) coordinate (a) arc[start angle=\zr,end angle=\zr+90,radius=0.3]}{[canvas is yz plane at x=3.25] --++ (0,0,0) arc[start angle=\zr+90,end angle=\zr,radius=0.3]} --cycle;
\fill[gray!40]{[canvas is yz plane at x=2.75] (0,3.25,0) ++ (\zr+90:0.3) coordinate (a) arc[start angle=\zr+90,end angle=\zr+180,radius=0.3]}{[canvas is yz plane at x=3.25] --++ (0,0,0) arc[start angle=\zr+180,end angle=\zr+90,radius=0.3]} --cycle;
\fill[gray!40]{[canvas is yz plane at x=2.75] (0,3.25,0) ++ (\zr+180:0.3) coordinate (b) arc[start angle=\zr+180,end angle=\zr+270,radius=0.3]}{[canvas is yz plane at x=3.25] --++ (0,0,0) arc[start angle=\zr+270,end angle=\zr+180,radius=0.3]} --cycle;
\fill[gray!40]{[canvas is yz plane at x=2.75] (0,3.25,0) ++ (\zr+270:0.3) coordinate (b) arc[start angle=\zr+270,end angle=\zr+360,radius=0.3]}{[canvas is yz plane at x=3.25] --++ (0,0,0) arc[start angle=\zr+360,end angle=\zr+270,radius=0.3]} --cycle;
\draw[fill=gray!10]{[canvas is yz plane at x=3.25] (0,3.25,0) circle [radius=0.3]};
\end{scope}
% Second Arm
\begin{scope}[shift={(3,0,3.25)},rotate around x=\phi]
\draw[fill=gray!10] {[canvas is xy plane at z=0.3] circle [radius=0.1]};
\fill[gray!60]{[canvas is xy plane at z=0.3] (0,0,0) ++ (\zr:0.1) coordinate (a) arc[start angle=\zr,end angle=\zr+90,radius=0.1]}{[canvas is xy plane at z=2.3] --++ (0,0,0) arc[start angle=\zr+90,end angle=\zr,radius=0.1]} --cycle;
\fill[gray!60]{[canvas is xy plane at z=0.3] (0,0,0) ++ (\zr+90:0.1) coordinate (a) arc[start angle=\zr+90,end angle=\zr+180,radius=0.1]}{[canvas is xy plane at z=2.3] --++ (0,0,0) arc[start angle=\zr+180,end angle=\zr+90,radius=0.1]} --cycle;
\fill[gray!60]{[canvas is xy plane at z=0.3] (0,0,0) ++ (\zr+180:0.1) coordinate (a) arc[start angle=\zr+180,end angle=\zr+270,radius=0.1]}{[canvas is xy plane at z=2.3] --++ (0,0,0) arc[start angle=\zr+270,end angle=\zr+180,radius=0.1]} --cycle;
\fill[gray!60]{[canvas is xy plane at z=0.3] (0,0,0) ++ (\zr+270:0.1) coordinate (a) arc[start angle=\zr+270,end angle=\zr+360,radius=0.1]}{[canvas is xy plane at z=2.3] --++ (0,0,0) arc[start angle=\zr+360,end angle=\zr+270,radius=0.1]} --cycle;
\draw[fill=gray!10] {[canvas is xy plane at z=2.3] circle [radius=0.1]};
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
Setting the value for \zr
outputs:
And finally setting the value of \phi
outputs: