![使用 TikZ 在圆环(甜甜圈)周围绘制一个环](https://linux22.com/image/270926/%E4%BD%BF%E7%94%A8%20TikZ%20%E5%9C%A8%E5%9C%86%E7%8E%AF%EF%BC%88%E7%94%9C%E7%94%9C%E5%9C%88%EF%BC%89%E5%91%A8%E5%9B%B4%E7%BB%98%E5%88%B6%E4%B8%80%E4%B8%AA%E7%8E%AF.png)
我试图TikZ
根据上一个问题的答案,使用 绘制一个 2 圆环(甜甜圈)使用 Tikz 的 Moebius Strip,得到以下
结果令人印象深刻!然而,垂直圆看起来并没有围绕圆环。
问:
我怎样才能给出正确的 3D 视角?
平均能量损失
警告:我的计算机的主内存已增强以容纳此代码
\documentclass{report}
\usepackage{amsmath,units}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
hide axis,
view={60}{60}
]
\addplot3 [
surf, shader=interp,
point meta=x,
colormap/greenyellow,
samples=40,
samples y=40,
z buffer=sort,
domain=0:360,
y domain=0:360
] (
{(3.5 + 0.5*cos(y))*cos(x)},
{(3.5 + 0.5*cos(y))*sin(x)},
{0.5*sin(y)});
\addplot3 [
samples=40,
domain=0:360,
thick
] (
{(3.5 + 0.5*cos(80))*cos(x)},
{(3.5 + 0.5*cos(80))*sin(x)},
{0.5*sin(80)});
\addplot3 [
samples=40,
domain=0:360,
thick
] (
{3.5 + 0.5*cos(x)},
{0},
{0.5*sin(x)});
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您必须手动调整计算圆的域,以便它仅在可见的一侧绘制:
\documentclass{report}
\usepackage{amsmath,units}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
hide axis,
view={60}{30},
axis equal image,
]
\addplot3 [
surf, shader=interp,
point meta=x,
colormap/greenyellow,
samples=40,
samples y=20,
z buffer=sort,
domain=0:360,
y domain=0:360
] (
{(3.5 + 0.5*cos(y))*cos(x)},
{(3.5 + 0.5*cos(y))*sin(x)},
{0.5*sin(y)});
\addplot3 [
samples=40,
samples y=1,
domain=0:360,
thick
] (
{(3.5 + 0.5*cos(80))*cos(x)},
{(3.5 + 0.5*cos(80))*sin(x)},
{0.5*sin(80)});
\addplot3 [
samples=10,
samples y=1,
domain=-65:130,
thick
] (
{3.5 + 0.5*cos(x)},
{0},
{0.5*sin(x)});
\end{axis}
\end{tikzpicture}
\end{document}