为什么我的 Tikz 图片中的那些珠子互相重叠?

为什么我的 Tikz 图片中的那些珠子互相重叠?

在此处输入图片描述

我使用 Tikz 创建了这排珠子,但是我的图片中发生了奇怪的事情,但我确实指定了不能相互重叠的位置。

    % Rusting Iron
% Author: Jason Waskiewicz
% A "jazzy" picture of the stages of rust (presented for a high school level).
% Iron is red, oxygen is blue and electrons are black. At the left you see
% iron atoms with two oxygen molecules, then the electrons go to the oxygen molecules
% leaving oxygen ions and iron ions which then disolve.
\documentclass[tikz]{standalone}

\usetikzlibrary{positioning}
\usepackage{lmodern}
\newcommand{\tikzmark}[2]{\tikz[remember picture, baseline] \node[inner sep=0pt, outer sep=0pt, anchor=base] (#1) {#2};}


\begin{document}

\begin{tikzpicture}[
        >=stealth,
        %show background rectangle, 
        iron/.style={shade, ball color=red, opacity=1.9},
        electron/.style={shade, ball color=green},
        oxygen/.style={shade, ball color=blue},
        B/.style={ball color=yellow},
        A/.style={ball color=violet},
    ]


\foreach \x in {  -155.000000,   -152.500000,    -150.000000,    -147.500000,    -145.000000,    -142.500000,    -140.000000,    -137.500000,    -135.000000,    -132.500000,    -130.000000,    -127.500000,    -125.000000,    -122.500000,    -120.000000,    -117.500000,    -115.000000,    -112.500000,    -110.000000,    -107.500000,    -105.000000,    -102.500000,    -100.000000,    -97.500000,     -95.000000,     -92.500000,     -90.000000,     -87.500000,     -85.000000,     -82.500000,     -80.000000,     -77.500000,     -75.000000,     -72.500000,     -70.000000,     -67.500000,     -65.000000,     -62.500000,     -60.000000,     -57.500000,     -55.000000,     -52.500000,     -50.000000,     -47.500000,     -45.000000,     -42.500000,     -40.000000,     -37.500000,     -35.000000,     -32.500000,     -30.000000,     -27.500000,     -25.000000,     -22.500000,     -20.000000,     -17.500000,     -15.000000,     -12.500000,     -10.000000,     -7.500000,      -5.000000,      -2.500000,      0.000000,   2.500000,   5.000000,   7.500000,   10.000000,      12.500000,      15.000000,      17.500000,      20.000000,      22.500000,      25.000000,      27.500000,      30.000000,      32.500000,      35.000000,      37.500000,      40.000000,      42.500000,      45.000000,      47.500000,      50.000000,      52.500000,      55.000000,      57.500000,      60.000000,      62.500000,      65.000000,      67.500000,      70.000000,      72.500000,      75.000000,      77.500000,      80.000000,      82.500000,      85.000000,      87.500000,      90.000000,      92.500000,      95.000000,      97.500000,      100.000000,     102.500000,     105.000000,     107.500000,     110.000000,     112.500000,     115.000000,     117.500000,     120.000000,     122.500000,     125.000000,     127.500000,     130.000000,     132.500000,     135.000000,     137.500000,     140.000000,     142.500000,     145.000000,     147.500000,     150.000000,     152.500000,    }
\draw [oxygen] (\x,-40.0,0) circle (3.5);

\end{tikzpicture}
\end{document}

我认为可能是因为圆的半径,所以将半径从 3.5 改为 1,但问题仍然存在。

在此处输入图片描述

那么为什么会发生这种情况呢?

我确实是通过 C 程序生成这些位置的,所以我认为没有数字是错误的。

谢谢你!

答案1

或者简单来说:

\foreach \x in {-155.0,-152.5,...,152.5}
\draw [oxygen] (\x,-40.0,0) circle (3.5);

答案2

\foreach通过使用以下内容替换循环来充分利用 的功能:

\foreach \x in {0,...,123}
\draw [oxygen] (-155+\x*2.5,-40.0,0) circle (3.5);

相关内容