这可能是一个非常简单的答案,但我希望/需要这个圆柱体的侧面出现。目标是让它成为圆柱壳的旋转体积。
理想情况下,最简单的代码修复更好,因为这样我可以调整它并从中学习。(不需要厚度)
\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[3d view={30}{20}, declare function={h=1;r=2;}]
\draw[fill=blue!25,fill opacity=0.5]
(r,0,0)
-- plot[variable=\x,domain=360:0,smooth] ({r*cos(\x)},{r*sin(\x)},0)
-- plot[variable=\x,domain=0:360,smooth] ({r*cos(\x)},{r*sin(\x)},h);
\end{tikzpicture}
\end{document}
答案1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-2, xmax=2,
ymin=-2, ymax=2,
zmin=0, zmax=1,
axis equal,
axis lines=none,
]
\addplot3[
surf, shader=flat, blue,
opacity=0.5,
domain=0:360, samples=100,
domain y=0:1, samples y=2,
] ({2*cos(x)},{2*sin(x)},y);
\end{axis}
\end{tikzpicture}
\end{document}
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\azimuth}{25}
\pgfmathsetmacro{\elevation}{30}
\begin{axis}[
view={\azimuth}{\elevation},
colormap={mycolor}{color=(blue)color=(blue)},
xmin=-2, xmax=2,
ymin=-2, ymax=2,
zmin=0, zmax=1,
axis equal,
axis lines=none,
]
\addplot3[
surf, shader=interp,
opacity=0.5,
domain=\azimuth:180+\azimuth, samples=100,
domain y=0:1, samples y=2,
] ({2*cos(x)},{2*sin(x)},y);
\addplot3[
surf, shader=interp,
opacity=0.5,
domain=0:360, samples=100,
domain y=0:1, samples y=2,
] ({1.8*cos(x)},{1.8*sin(x)},y);
\addplot3[
surf, shader=interp,
opacity=0.5,
domain=-180+\azimuth:\azimuth, samples=100,
domain y=0:1, samples y=2,
] ({2*cos(x)},{2*sin(x)},y);
\end{axis}
\end{tikzpicture}
\end{document}