我想在 LaTeX 中绘制一个三维质量弹簧系统的示例(最好使用 TikZ 或 Asymptote)。请参阅以下示例:
(此图取自 Gibson 和 Mirtich (1997) 的文章)这里)
如果可能的话,我希望线圈能更逼真,就像这个例子一样这里。
以下是最小(部分工作)示例。我只需要用弹簧连接每个平面上的点即可完成:
\documentclass{standalone}
\usepackage{luatex85}
\usepackage[inline]{asymptote}
\begin{document}
\begin{asy}
settings.tex = "lualatex";
import three;
settings.prc = false;
settings.render = 0;
size(10cm);
currentprojection = orthographic(-1, 0.5, 0.5, up=Y);
draw(unitbox, pink);
for (int i = 0; i <= 3; ++i)
{
for (int j = 0; j <= 3; ++j)
{
// plane "X" in Unity
dot((0, i/3, j/3), magenta);
// plane "Y"
dot((i/3, 1, j/3), red);
// planz "Z"
dot((i/3, j/3, 1), black);
}
}
\end{asy}
\end{document}
我怎样才能完成它?
答案1
有了这样的弹簧你会满意吗?
\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{
decorations,
decorations.pathmorphing,
}
\begin{document}
\begin{tikzpicture}[
decoration={
coil,
amplitude = 1.5mm,
aspect=1,
pre length=1mm,
post length=1mm,
},
every node/.style={circle, draw}
]
\foreach \x in {0,4,...,12}{
\let\lasty\undefined
\foreach \y in {0,3,...,6}{
\let\lastz\undefined
\foreach \z in {0,3,6}{
\begin{scope}[draw=black!\z0!gray]
\node[fill=black!\z0] (n\x\y\z) at (\x,\y,\z) {};
\ifx\lastx\undefined\else
\draw[decorate] (n\x\y\z) -- (n\lastx\y\z);
\fi
\ifx\lasty\undefined\else
\draw[decorate] (n\x\y\z) -- (n\x\lasty\z);
\fi
\ifx\lastz\undefined\else
\draw[decorate] (n\x\y\z) -- (n\x\y\lastz);
\fi
\end{scope}
\xdef\lastz{\z}
};
\xdef\lasty{\y}
};
\xdef\lastx{\x}
};
\end{tikzpicture}
\end{document}