我试图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}