知道如何在 LaTeX 中绘制这个吗?可能吗?下面的 MWE(来自 Hugues Vermeiren 的示例代码)仅生成一个短圆柱体。我不知道如何进行剪切,所以我可能会放弃它并在整个正面画一些小孔。但如果有人可以剪切,请提前致谢。
\documentclass{standalone}
\usepackage{tikz}
\tikzset{Persp/.style={scale=2.8,x={(-0.8cm,-0.4cm)},y={(0.8cm,-0.4cm)},
z={(0cm,.5cm)}}}
\begin{document}
\begin{tikzpicture}[Persp]
\def\h{.75}% cylinder length
\def\a{35}
\begin{scope}[rotate=-90]
\foreach \t in {140,320}
\draw[black, very thick] ({cos(\t)},{sin(\t)},0)--({cos(\t)},{sin(\t)},
{2.0*\h});
\draw[black,very thick] (1,0,0) % front outer circle
\foreach \t in {5,10,...,360}
{--({cos(\t)},{sin(\t)},0)}--cycle;
\draw[black,very thick] (.8,0,0) % front inner circle
\foreach \t in {5,10,...,360}
{--({.8*cos(\t)},{.8*sin(\t)},0)}--cycle;
\draw[black,very thick] (1,0,{2*\h}) % bacl outer circle
\foreach \t in {10,20,...,360}
{--({cos(\t)},{sin(\t)},{2*\h})}--cycle;
\foreach \t in {5,10,...,360}
{--({sin(\t)},{cos(\t)},{-tan(\a)*cos(\t)+\h})}--cycle;
\end{scope}
\end{tikzpicture}
\end{document}
答案1
当我在等待学生的考试成绩时,我开始画这个。
这是一些相当临时的代码...请不要评判我。
无论如何,输出
代码
\documentclass[12pt,tikz,border=2pt]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc}
\begin{document}
\tikzset
{
copper/.style={fill=red!50},
coating/.style={fill=gray},
}
\def\angThe{40}
\def\angPhi{50}
\tdplotsetmaincoords{\angThe}{\angPhi}
\begin{tikzpicture}[scale=4,tdplot_main_coords]
\def\R{2} % radius of the inner plate
\def\RR{2.2} % outer radius
\def\d{.08} % space between holes
\def\r{.03} % radius of holes
\def\z{2} % thickness of the cake
% translation vector between plates
\coordinate (vert) at (0,0,\z);
\pgfmathtruncatemacro{\ratio}{ceil(1.414*\R/\d)}
\newcommand\usefulCoords
{
\coordinate(o) at (0,0);
\coordinate(i) at (0:1);
\coordinate(j) at (60:1);
\coordinate(k) at (-60:1);
}
\begin{scope}
\usefulCoords
\clip (\angPhi:-\R) -- (\angPhi+90:.9*\R) -- (\angPhi:\R) -- ++ (\angPhi-90:\R) -- ++ (\angPhi:-2*\R) -- cycle;
\clip (o) -- (\R,0) arc (0:300:\R) -- cycle;
%\fill [fill=white] (o) -- (\R,0) arc (0:300:\R) -- cycle;
\foreach \x [evaluate=\x as \i using \x*\d] in {0,...,\ratio}
{
\draw [fill=white] ($(o)+\i*(i)$) circle (\r)
($(o)+\i*(k)$) circle (\r);
}
\end{scope}
\begin{scope}[shift={(vert)}]
\usefulCoords
\clip (o) -- (\R,0) arc (0:300:\R) -- cycle;
\draw [copper] (o) -- (\R,0) arc (0:300:\R) -- cycle;
\foreach \x [evaluate=\x as \i using \x*\d] in {-\ratio,...,\ratio}
{
\foreach \y [evaluate=\y as \j using \y*\d] in {-\ratio,...,\ratio}
{
\draw [fill=white] ($(o)+\i*(i)+\j*(j)$) circle (\r);
}
}
\end{scope}
\pgfmathtruncatemacro{\ffloor}{floor(\R/\d)-1}
\usefulCoords
\foreach \x [evaluate=\x as \i using \x*\d] in {1,...,\ffloor}
{
\draw [fill=white,] ($(o)+\i*(i)+\r*(i)$) arc (0:180:\r) -- ++ (vert) arc (180:0:\r) -- cycle;
\draw [fill=white,] ($(o)+\i*(k)+\r*(k)$) arc (300:120:\r) -- ++ (vert) arc (120:300:\r) -- cycle;
}
\foreach \x [evaluate=\x as \i using \x*\d] in {0,...,\ffloor}
{
\draw [copper] ($(o)+\i*(i)+\r*(i)$) -- ++ (vert)-- ++ (${\d-2*\r}*(i)$) -- ++($-1*(vert)$) -- cycle;
\draw [copper] ($(o)+\i*(k)+\r*(k)$) -- ++ (vert)-- ++ (${\d-2*\r}*(k)$) -- ++($-1*(vert)$) -- cycle;
}
\begin{scope}[shift={(vert)}]
\draw [coating] (\R,0) -- (\RR,0) arc (0:300:\RR) -- (300:\R) arc (300:0:\R) -- cycle;
\end{scope}
\draw (\angPhi:-\RR) -- ++ (vert)
(\angPhi:\RR) -- ++ (vert);
\draw (\angPhi:\RR) arc (\angPhi:0:\RR) -- (0:\R)
(\angPhi:-\RR) arc (\angPhi:120:-\RR) -- (120:-\R);
\draw [coating] (120:-\R) -- ++(vert) -- ++(300:\RR-\R) -- (120:-\RR)
(0:\R) -- ++(vert) -- ++(0:\RR-\R) -- (0:\RR);
\end{tikzpicture}
\end{document}