答案1
我把 设为\Angle
角度phi
,并考虑\Angle
从 0 到 180 和\Angle
从 180 到 360 的两种情况。例如,\Angle = 70
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools,calc}%https://github.com/marmotghost/tikz-3dtools
\begin{document}
\foreach \Angle in {70}
{\begin{tikzpicture}[3d/install view={phi=\Angle,theta=70},line cap=round,line join=round,c/.style={circle,fill,inner sep=1pt},
declare function={R=2;h=4;}]
\path[save named path=cyl] pic{3d/frustum={R=R,r=R,h=h}};
\draw[3d/hidden] plot[smooth,domain=180-\Angle+\pgfkeysvalueof{/tikz/3d/phi}:\Angle] ({R*cos(\x)},{R*sin(\x)},{R*sin(\x)});
\draw[3d/visible] plot[smooth,domain=\pgfkeysvalueof{/tikz/3d/phi}:0] ({R*cos(\x)},{R*sin(\x)},{R*sin(\x)});
\draw[3d/hidden] (0:R) -- (180:R);
\end{tikzpicture}}
\end{document}
你可以这样使用
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools,calc}%https://github.com/marmotghost/tikz-3dtools
\begin{document}
\foreach \Angle in {5,10,...,175}
{\begin{tikzpicture}[3d/install view={phi=\Angle,theta=70},line cap=round,line join=round,c/.style={circle,fill,inner sep=1pt},
declare function={R=2;h=4;}]
\path[save named path=cyl] pic{3d/frustum={R=R,r=R,h=h}};
\draw[3d/hidden] plot[smooth,domain=180-\Angle+\pgfkeysvalueof{/tikz/3d/phi}:\Angle] ({R*cos(\x)},{R*sin(\x)},{R*sin(\x)});
\draw[3d/visible] plot[smooth,domain=\pgfkeysvalueof{/tikz/3d/phi}:0] ({R*cos(\x)},{R*sin(\x)},{R*sin(\x)});
\draw[3d/hidden] (0:R) -- (180:R);
\end{tikzpicture}}
\end{document}
使用\Angle = 300
我的代码
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools,calc}%https://github.com/marmotghost/tikz-3dtools
\begin{document}
\foreach \Angle in {300}
{\begin{tikzpicture}[3d/install view={phi=\Angle,theta=70},line cap=round,line join=round,c/.style={circle,fill,inner sep=1pt},
declare function={R=2;h=4;}]
\path[save named path=cyl] pic{3d/frustum={R=R,r=R,h=h}};
\draw[3d/hidden] plot[smooth,domain=0:\Angle-180] ({R*cos(\x)},{R*sin(\x)},{R*sin(\x)});
\draw[3d/visible] plot[smooth,domain=\Angle-180:180] ({R*cos(\x)},{R*sin(\x)},{R*sin(\x)});
\draw[3d/hidden] (0:R) -- (180:R);
\end{tikzpicture}}
\end{document}
或者你可以使用
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools,calc}%https://github.com/marmotghost/tikz-3dtools
\begin{document}
\foreach \Angle in {185,190,...,355}
{\begin{tikzpicture}[3d/install view={phi=\Angle,theta=70},line cap=round,line join=round,c/.style={circle,fill,inner sep=1pt},
declare function={R=2;h=4;}]
\path[save named path=cyl] pic{3d/frustum={R=R,r=R,h=h}};
\draw[3d/hidden] plot[smooth,domain=0:\Angle-180] ({R*cos(\x)},{R*sin(\x)},{R*sin(\x)});
\draw[3d/visible] plot[smooth,domain=\Angle-180:180] ({R*cos(\x)},{R*sin(\x)},{R*sin(\x)});
\draw[3d/hidden] (0:R) -- (180:R);
\end{tikzpicture}}
\end{document}