使用 Tikz 进行球体相交

使用 Tikz 进行球体相交

我发现这个例子这里两个相交的球体,复制了我发现的几个 Tikz 球体这里代码如下。不过,我想知道如何让这两个球体相交 - 以及如何将它们嵌入/绘制一个更大的球体,该球体在 XY 平面上刚好足够容纳这两个球体。

我考虑得更笼统一些——也许我可以创建一个通用的“球体”,实例化 3 个不同大小的球体,然后移动它们,直到它们看起来正确为止。这可能是个好办法。

感谢您的见解。

\documentclass[tikz,border=10pt]{standalone}
    \begin{figure}[htb]
    \tdplotsetmaincoords{55}{5}
    \begin{tikzpicture}
        [scale=3,
            tdplot_main_coords,
            curve/.style={black}]

        \coordinate (O) at (0,0,0);

        \foreach \angle in {-90,-75,...,90}
        {
            %calculate the sine and cosine of the angle
            \tdplotsinandcos{\sintheta}{\costheta}{\angle}%

            %define a point along the z-axis through which to draw
            %a circle in the xy-plane
            \coordinate (P) at (0,0,\sintheta);

            %draw the circle in the main frame
            \tdplotdrawarc[curve]{(P)}{\costheta}{0}{360}{}{}

            %define the rotated coordinate frame based on the angle
            %\tdplotsetthetaplanecoords{\angle}

            %draw the circle in the rotated frame
            %\tdplotdrawarc[curve,tdplot_rotated_coords]{(O)}{1}{0}{360}{}{}
        }

    \end{tikzpicture}
    \tdplotsetmaincoords{30}{5}
    \begin{tikzpicture}
        [scale=2,
            tdplot_main_coords,
            curve/.style={black}]

        \coordinate (O) at (-130,0,0);

        \foreach \angle in {-90,-75,...,90}
        {
            %calculate the sine and cosine of the angle
            \tdplotsinandcos{\sintheta}{\costheta}{\angle}%

            %define a point along the z-axis through which to draw
            %a circle in the xy-plane
            \coordinate (P) at (0,0,\sintheta);

            %draw the circle in the main frame
            \tdplotdrawarc[curve]{(P)}{\costheta}{0}{360}{}{}

            %define the rotated coordinate frame based on the angle
            %\tdplotsetthetaplanecoords{\angle}

            %draw the circle in the rotated frame
            %\tdplotdrawarc[curve,tdplot_rotated_coords]{(O)}{1}{0}{360}{}{}
        }

    \end{tikzpicture}
    \end{figure}
 \end{document}

相关内容