如何用 Tikz 创建三种类型的圆柱体?

如何用 Tikz 创建三种类型的圆柱体?

我想要创建三种不同类型的圆柱体,如下所示:

圆柱

谁能帮我?

答案1

这是与 Ti 一起工作的可能性Z 库perspective用于设置 3D 视图。其余部分包括绘制大量圆弧和几条线。如下所示:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{perspective}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,isometric view,rotate around z=315,yscale=0.5]
\pgfmathsetmacro\a{atan(4/3)}
\def\h{3} % height
% first cylinder
\fill[cyan!30] (0,0) circle (2);
\draw[dashed] (-2,0) arc (180:0:2);
\draw (-2,0,\h) --++ (0,0,-\h) arc (180:360:2) --++ (0,0,\h);
\draw (0,0,\h) circle (2);
\node at (0,0) {$A$};
% second cylinder
\begin{scope}[shift={(6,0)}]
\fill[cyan!30,even odd rule] (0,0) circle (2) (0,0) circle (1);
\draw[dashed] (-2,0) arc (180:0:2);
\draw         (-2,0,\h) --++ (0,0,-\h) arc (180:360:2) --++ (0,0,\h);
\foreach\i in {1,2}
  \draw       (0,0,\h) circle (\i);
\draw[dashed] (0,0) circle (1);
\foreach\i in {-1,1}
  \draw[dashed] (\i,0,0) -- (\i,0,\h);
\node at (-1.5,0) {$A$};
\end{scope}
% third cylinder
\begin{scope}[shift={(12,0)}]
\fill[cyan!30] (\a:2) arc (\a:360-\a:2) arc (180-\a:90:3) arc (-90:90:1) arc (270:180+\a:3);
\draw[dashed]  (-2,0) arc (180:\a:2) arc (180+\a:270:3) arc (90:0:1);
\draw          (-2,0,\h) --++ (0,0,-\h) arc (180:360-\a:2) arc (180-\a:90:3) arc (-90:0:1) --++ (0,0,\h);
\draw          (\a:2) + (0,0,\h) arc (\a:360-\a:2) arc (180-\a:90:3) arc (-90:90:1) arc (270:180+\a:3);
\node at (0,0) {$A$};
\end{scope}
% heights
\foreach\i in {2,8,16}
{
  \foreach\j in {0,\h}
    \draw[red] (\i,0,\j) -- (\i+1,0,\j);
  \draw[red,latex-latex] (\i+0.75,0,0) -- (\i+0.75,0,\h) node[midway,right] {$h$};
}
\end{tikzpicture}
\end{document}

在此处输入图片描述 或者,删除该选项yscale=0.5并改变高度,\def\h{2}你会得到一个真正等距的图形: 在此处输入图片描述

相关内容