对于一个工业问题,我希望能够绘制一系列多股电线横截面的布局。这些可以通过在圆形包络中填充给定数量的给定直径的切线圆来简化。我想要制作的典型布局是圆(股)数为 19 且密度为 8.03 的布局,如本页所示:https://en.wikipedia.org/wiki/Circle_packing_in_a_circle 理想情况下,我希望改变圆的数量及其直径,并至少为流行的配置轻松重新生成新的布局,例如 7、19、37 股线的数量……(较大的电线具有“绳索”配置,即一捆较小的电线束,更复杂,但不在范围内)。我无法衡量这个问题的难度,最初在我看来相对简单,更不用说决定如何开始。有人可以提供指导吗?
\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,backgrounds}
\begin{document}
\tiny
\begin{tikzpicture}[cable/.style={circle, draw, minimum size=5mm, inner sep=0pt, outer sep=0pt}]
\node[cable] (center) at (0,0) {};
\foreach \i in {1,...,6}
\node[cable] (0-\i) at (60*\i:5mm) {a\i};
% \foreach \i in {6}
% \node[cable] (1-\i) at (60*\i:5mm) {\i};
\foreach \i in {1,...,12}
\node[cable,red] (1-\i) at ({15+30*\i}:.97) {b\i};
\foreach \i in {1,...,12}
\node[cable, blue] (1-\i) at ({0+30*\i}:1.37) {c\i};
\begin{scope}[on background layer]
%\node[circle, draw, blue, fit=(2-1) (2-7), inner sep=-1.8pt] (envelope) {};
\end{scope}
\end{tikzpicture}
\end{document}
答案1
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{fit,backgrounds}
\begin{document}
\begin{tikzpicture}[cable/.style={circle, fill=blue!30!black, minimum size=10mm, inner sep=0pt, outer sep=0pt}]
\node[cable] (center) at (0,0) {};
\foreach \i in {0,1,...,6}
\node[cable] (1-\i) at (60*\i:10mm) {};
\foreach \i in {0,1,...,12}
\node[cable] (2-\i) at ({15+30*\i}:1.9315) {};
\begin{scope}[on background layer]
\node[circle, fill=blue!30, fit=(2-1) (2-7), inner sep=-3pt] (envelope) {};
\end{scope}
\end{tikzpicture}
\end{document}
对于 37 来说,神奇的数字来自http://hydra.nat.uni-magdeburg.de/packing/cci/d4.html效果不太好。在这种情况下,我使用了circle
而不是nodes
。
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[red!40] circle (1);
\fill[blue!40!red] circle (.1479559);
\foreach \i in {0,1,...,6}
\fill[blue!30!red] (60*\i:.2959118) circle (.1479559);
\foreach \i in {0,1,...,12}
\fill[blue!20!red] ({15+30*\i}:0.5715536) circle(.1479559);
\foreach \i in {0,1,...,18}
\fill[blue!10!red] ({10+20*\i}:0.852045) circle(.1479559);
\end{tikzpicture}
\end{document}