![如何用 TikZ 绘制无限耳环?](https://linux22.com/image/306498/%E5%A6%82%E4%BD%95%E7%94%A8%20TikZ%20%E7%BB%98%E5%88%B6%E6%97%A0%E9%99%90%E8%80%B3%E7%8E%AF%EF%BC%9F.png)
我想画一个无限大的耳环,即每个圆以 为中心,每个圆的$(\frac{1}{n},0)$
半径为。图形如下: $\frac{1}{n}$
$n\in \mathbf{N}$
我使用了下面的代码来绘制图表:
\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\begin{document}
\begin{tikzpicture}
\foreach \n in {1,2,3,4,5,6,7,...................}
\draw (1/\n,0) circle (1/\n);
\foreach \n in {1,2,3,4,5,6,7,...................}
\draw[fill] (1\n,0) circle (0.5pt);
\end{tikzpictute}
\end{document}
但它显示错误。
答案1
可能比无穷大更好,如果你固定一个大数字
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \n in {1,2,...,2000}
\draw (1/\n,0) circle (1/\n);
\end{tikzpicture}
\end{document}
编辑:我们可以替换
\foreach \n in {1,2,...,2000}
经过
\foreach \n in {1,...,2000}
因为步骤是 1
答案2
无法抗拒添加这个的 MetaPost 版本。
\documentclass{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
r = 10cm; % Unit
d = 2r;
beginfig(1);
for n = 1 upto 1000: draw fullcircle scaled (d/n) shifted (r/n, 0) ; endfor
endfig;
\end{mplibcode}
\end{document}
与 LuaLaTeX 一起运行。
答案3
利用节点对齐属性的另一种解决方案:
\documentclass[tikz,border=10pt]{standalone}
\pgfkeys{tikz/.cd,
num of circles/.store in=\numcirc,
num of circles=100,
circle initial size/.store in=\circlesize,
circle initial size=3cm,
}
\begin{document}
\begin{tikzpicture}
\foreach \n in {1,...,\numcirc}{
\pgfmathsetmacro\actualsize{\circlesize/\n}
\node[anchor=west,circle,draw,inner sep=\actualsize pt] at (0,0){};
}
\end{tikzpicture}
\end{document}
结果:
答案4
PSTricks 解决方案:
\documentclass{article}
\usepackage{multido}
\usepackage{pstricks}
\usepackage{xfp}
% parameters
\def\circles{100}
\def\radius{3}
\begin{document}
\begin{pspicture}(\fpeval{2*\radius},\fpeval{2*\radius})
\multido{\i = 1+1}{\circles}{\pscircle(\fpeval{\radius/\i},\radius){\fpeval{\radius/\i}}}
\end{pspicture}
\end{document}
...如果用太粗的笔来绘制圆周:
\documentclass{article}
\usepackage{multido}
\usepackage{pstricks}
\usepackage{xfp}
% parameters
\def\circles{100}
\def\radius{3}
\begin{document}
\begin{pspicture}(\fpeval{2*\radius},\fpeval{2*\radius})
\multido{\i = 1+1}{\circles}{\pscircle[linewidth = 0.5\pslinewidth](\fpeval{\radius/\i},\radius){\fpeval{\radius/\i}}}
\end{pspicture}
\end{document}