我借用了一些代码这一页并对其进行了稍微的修改,得到如下结果:
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{through}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (0,0) circle (3cm);
\draw (0,0) circle (3cm);
\end{scope}
\coordinate (a) at (90:3);
\coordinate (b) at (-30:3);
\coordinate (c) at (210:3);
\foreach \in in {1,2,...,4}
{
\node[circle through=(a),draw] {};
\draw (a)--(b)--(c)--cycle;
\coordinate(aux) at (a);
\path (a)--(b) coordinate[pos=.5] (a);
\path (b)--(c) coordinate[pos=.5] (b);
\path (c)--(aux) coordinate[pos=.5] (c);
}
\end{tikzpicture}
\end{document}
得出的结果是:
我希望去掉最外层的圆;因此进行了范围界定和裁剪。但这没有奏效。我还尝试将命令放在命令clip
后面draw
,并向环境添加一个clip
选项scope
。有没有办法clip
做我想做的事情?(看起来有一种方法可以从三角形开始,然后从那里计算,就像这次讨论,但我希望避免这种程度的复杂化。
答案1
此代码覆盖节点并重绘圆圈。最小的手术可能是
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{through}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (90:3);
\coordinate (b) at (-30:3);
\coordinate (c) at (210:3);
\foreach \in in {1,2,...,4}
{
\ifnum\in=1
\else
\node[circle through=(a),draw] {};
\fi
\draw (a)--(b)--(c)--cycle;
\coordinate(aux) at (a);
\path (a)--(b) coordinate[pos=.5] (a);
\path (b)--(c) coordinate[pos=.5] (b);
\path (c)--(aux) coordinate[pos=.5] (c);
}
\end{tikzpicture}
\end{document}
答案2
在循环中,首先绘制圆圈,(在循环的开始处)(a)
然后用 重新定义点\coordinate(aux) at (a);
,因此在循环的末尾而不是开头绘制圆就足够了。
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{through}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (0,0) circle (3cm);
%\draw (0,0) circle (3cm);
\end{scope}
\coordinate (a) at (90:3);
\coordinate (b) at (-30:3);
\coordinate (c) at (210:3);
\foreach \in in {1,2,...,4}
{
%\node[circle through=(a),draw] {};
\draw (a)--(b)--(c)--cycle;
\coordinate(aux) at (a);
\path (a)--(b) coordinate[pos=.5] (a);
\path (b)--(c) coordinate[pos=.5] (b);
\path (c)--(aux) coordinate[pos=.5] (c);
\node[circle through=(a),draw] {};% draw the circle at the end
}
\end{tikzpicture}
\end{document}
答案3
- 将最外面的三角形放在循环之外
- 减少迭代次数
- 循环首先计算新坐标 (a)、(b) 和 (c)
!
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (90:3);
\coordinate (b) at (-30:3);
\coordinate (c) at (210:3);
\draw(a)--(b)--(c)--cycle;
\foreach \in in {1,2,...,3}
{
\coordinate(aux) at (a);
\path (a)--(b) coordinate[pos=.5] (a);
\path (b)--(c) coordinate[pos=.5] (b);
\path (c)--(aux) coordinate[pos=.5] (c);
\node[circle through=(a),draw] {};
\draw (a)--(b)--(c)--cycle;
}
\end{tikzpicture}
\end{document}