如何使用 tikzpicture 绘制空心圆柱体

如何使用 tikzpicture 绘制空心圆柱体

有人可以建议修改下面的代码,以便我最终得到一个漂亮的空心圆柱体,如下面的手绘图像所示?

我想要这个输出

尝试了几分钟,但对我来说有点困难。

太感谢了!

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepackage{fancyhdr}
\usepackage{bigints}
\usepackage{color}
\usepackage{tcolorbox}
\usepackage{color,xcolor}
\usepackage{booktabs,array}
\usepackage{hyperref}
\usepackage{graphicx}
\usetikzlibrary{arrows}
\usepackage{polynom}
\usepackage{wallpaper}
\usetikzlibrary{shapes.misc}
\usepackage{flexisym}
\usepackage{caption}
\usetikzlibrary{arrows}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\begin{center}
\begin{tikzpicture}
%cylinder
\draw [thick](-1.5,-1.65) -- (-1.5,1.65);
\draw [thick](+1.5,-1.65) -- (+1.5,1.65);
\draw [thick](-1.5,-1.65) arc (180:360:1.5 and 0.25);
\draw[thick,dashed] (1.5,-1.65) arc (-1.65:180:1.5 and 0.25);
\draw [thick](-1.5,+1.65) arc (180:360:1.5 and 0.25);
\draw [thick](+1.5,+1.65) arc (-1.5:180:1.5 and 0.25);
\draw[thick,gray,dashed](0,-1.65) --(+1.5,-1.65);
%hollow
\draw [thick](-1,-1.65) -- (-1,1.65);
\draw [thick](+1,-1.65) -- (+1,1.65);
\draw [thick](-1,-1.65) arc (180:360:1 and 0.25);
\draw[thick,dashed] (1,-1.65) arc (-1.65:180:1 and 0.25);
\draw [thick](-1,+1.65) arc (180:360:1 and 0.25);
\draw [thick](+1,+1.65) arc (-1:180:1 and 0.25);
\draw[thick,gray,dashed](0,-1.65) --(+1,-1.65);
%
%\fill[fill=black] (0,-1.65) circle (1.5pt);
%\node[below,scale=0.8] at (1.2,-2) {$R$};
\draw [thick,<->] (0,-2.3) -- node[fill=white,scale=0.9] {$0.5$ \text{m}} (1.5,-2.3);
\draw [thick,<->] (2.1,1.65) -- node[fill=white,scale=0.9] {$h$ \text{cm}} (2.1,-1.65);
\newline
\end{tikzpicture}
\end{center}
\end{document}

答案1

稍微改变椭圆弧的下半径。

在此处输入图片描述

\documentclass[margin=2pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
%cylinder
\draw [thick](-1.5,-1.65) -- (-1.5,1.65);
\draw [thick](+1.5,-1.65) -- (+1.5,1.65);
\draw [thick](-1.5,-1.65) arc (180:360:1.5 and 0.5);          % <--
\draw[thick,dashed] (1.5,-1.65) arc (-1.65:180:1.5 and 0.5);  % <--
\draw [thick](-1.5,+1.65) arc (180:360:1.5 and 0.5);          % <--
\draw [thick](+1.5,+1.65) arc (-1.5:180:1.5 and 0.5);         % <--
\draw[thick,gray,dashed](0,-1.65) --(+1.5,-1.65);
%hollow
\draw [thick](-1,-1.65) -- (-1,1.65);
\draw [thick](+1,-1.65) -- (+1,1.65);
\draw [thick](-1,-1.65) arc (180:360:1 and 0.25);
\draw[thick,dashed] (1,-1.65) arc (-1.65:180:1 and 0.25);
\draw [thick](-1,+1.65) arc (180:360:1 and 0.25);
\draw [thick](+1,+1.65) arc (-1:180:1 and 0.25);
\draw[thick,gray,dashed](0,-1.65) --(+1,-1.65);
%
%\fill[fill=black] (0,-1.65) circle (1.5pt);
%\node[below,scale=0.8] at (1.2,-2) {$R$};
%%
%% I changed a little the node position; removed \text{}
%% node for R_1 below
\draw [thick,<->] (0,-1.5) -- node[fill=white,inner sep=1pt] {\scriptsize$R_1$} (1,-1.5);
\draw [thick,<->] (0,-2.5) -- node[fill=white,scale=0.9,inner sep=1pt] {$0.5$ m} (1.5,-2.5);
\draw [thick,<->] (2.1,1.65) -- node[fill=white,scale=0.9, inner sep=1pt] {$h$ cm} (2.1,-1.65);
\end{tikzpicture}
\end{document}

相关内容