在 TikZ 中连接弧形路径

在 TikZ 中连接弧形路径

我正在尝试绘制一个球体的八分圆。我不是绘制透视图的专家,但我用弧形命令等方法做到了这一点。绘制球体后,我再次使用弧形命令创建了一些图层,我想填充这些图层以帮助将它们与其他图层区分开来。我为其中一个图层创建了一条路径,并对其进行了填充,但没有达到预期的效果。这条路径对我来说似乎是封闭的,但对 TikZ 来说却不是。我该如何关闭弧形路径并填充它?我猜我对坐标的手动微调可能是导致问题的原因?

平均能量损失

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{through,shapes}

\begin{document}
\begin{tikzpicture}
    % coordinaten
    \coordinate (m) at (0,4,0);
    % assen
    \draw (0,0,0) -- (0,4,0); % z
    \draw (0,0,0) -- (4,0,0); % x
    \draw (0,0,0) -- (0,0,4.65); % y
    % sfeer
    \draw (4,0,0) arc (0:116.5:4cm and -2cm);
    \draw (4,0,0) arc (0:90:4cm and 4cm);
    \draw (0,4,0) arc (90:206.5:2cm and 4cm);
    \node[draw,circle through={(m)}] (c) at (0,0,0) {};
    % fotosfeer
    \draw (3.875,0,0) arc (0:115.8:3.875cm and -1.875cm);
    \draw (3.875,0,0) arc (0:90:3.875cm and 3.875cm);
    \draw (0,3.875,0) arc (90:205.8:1.875cm and 3.875cm);
    % convenctie zone
    \draw (2,0,0) arc (0:116.5:2cm and -1cm);
    \draw (2,0,0) arc (0:90:2cm and 2cm);
    \draw (0,2,0) arc (90:206.5:1cm and 2cm);
    % radiatie zone
    \draw (1,0,0) arc (0:116.5:1cm and -0.5cm);
    \draw (1,0,0) arc (0:90:1cm and 1cm);
    \draw (0,1,0) arc (90:206.5:0.5cm and 1cm);
    % fill
    \draw[fill=blue] (0,3.875,0) -- (0,2,0) (3.875,0,0) arc (0:90:3.875cm and 3.875cm) (2,0,0) arc (0:90:2cm and 2cm) (3.875,0,0) -- (2,0,0);
\end{tikzpicture}
\end{document}

道路虽然被填满,但并未封闭

我想要填充的部分是 xz 平面的最大部分,其中 x 轴指向东,z 轴指向北。使用类似的代码,我最终也想填充相应的两个部分。

附言:我使用圆圈命令而不是普通的圆圈节点,这样缩放图形就不会出现问题。

答案1

你是指这样的事吗?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{through,shapes}

\begin{document}
\begin{tikzpicture}
    % coordinaten
    \coordinate (m) at (0,4,0);
    % assen
    \draw (0,0,0) -- (0,4,0); % z
    \draw (0,0,0) -- (4,0,0); % x
    \draw (0,0,0) -- (0,0,4.65); % y
    % sfeer
    \draw (4,0,0) arc (0:116.5:4cm and -2cm);
    \draw (4,0,0) arc (0:90:4cm and 4cm);
    \draw (0,4,0) arc (90:206.5:2cm and 4cm);
    \node[draw,circle through={(m)}] (c) at (0,0,0) {};
    % fotosfeer
    \draw (3.875,0,0) arc (0:115.8:3.875cm and -1.875cm);
    \draw (3.875,0,0) arc (0:90:3.875cm and 3.875cm);
    \draw (0,3.875,0) arc (90:205.8:1.875cm and 3.875cm);
    %fill
    \draw[fill=blue] (0,0,0) --(0,3.875,0) arc (90:205.8:1.875cm and 3.875cm) --(0,0,0) -- (3.875,0,0)  arc (0:90:3.875cm and 3.875cm) -- (0,0,0) -- (3.875,0,0) arc (0:115.8:3.875cm and -1.875cm)--  cycle;
    % convenctie zone
    \draw (2,0,0) arc (0:116.5:2cm and -1cm);
    \draw (2,0,0) arc (0:90:2cm and 2cm);
    \draw (0,2,0) arc (90:206.5:1cm and 2cm);
    %fill
    \draw[fill=red] (0,0,0) -- (0,2,0) arc (90:206.5:1cm and 2cm) --(0,0,0) -- (2,0,0)  arc (0:90:2cm and 2cm) -- (0,0,0) -- (2,0,0) arc (0:116.5:2cm and -1cm)--  cycle;
    % radiatie zone
    \draw (1,0,0) arc (0:116.5:1cm and -0.5cm);
    \draw (1,0,0) arc (0:90:1cm and 1cm);
    \draw (0,1,0) arc (90:206.5:0.5cm and 1cm);
    %fill
    \draw[fill=green] (0,0,0) -- (0,1,0) arc (90:206.5:0.5cm and 1cm) --(0,0,0) -- (1,0,0)  arc (0:90:1cm and 1cm) -- (0,0,0) -- (1,0,0) arc (0:116.5:1cm and -0.5cm)--  cycle;

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我认为你只是“扭曲”了路径。你需要绕到外面才能让填充起作用。

至少,如果我正确理解了你想要做的事情。请注意,我稍作了调整,但你需要进一步整理……

球体:切片和切块

\documentclass{standalone}
\usepackage[rgb]{xcolor}
\usepackage{tikz}
\usetikzlibrary{through}

\begin{document}
\begin{tikzpicture}[inner sep=0, outer sep=0]
    % coordinaten
    \coordinate (m) at (0,4,0);
    % assen
    \draw  (0,0,0) -- (0,4,0); % z
    \draw  (0,0,0) -- (4,0,0); % x
    \draw  (0,0,0) -- (0,0,4.65); % y
    % sfeer
    \draw (4,0,0) arc (0:116.5:4cm and -2cm);
    \draw (4,0,0) arc (0:90:4cm and 4cm);
    \draw (0,4,0) arc (90:206.5:2cm and 4cm);
    \node[draw, inner color=black!50, outer color=black!75, circle through={(m)}] (c) at (0,0,0) {};
    \node [ball color=purple, fill opacity=.25, circle through={(m)}] at (0,0,0) {};
    % fotosfeer
    \draw (3.875,0,0) arc (0:115.8:3.875cm and -1.875cm);
    \draw (3.875,0,0) arc (0:90:3.875cm and 3.875cm);
    \draw (0,3.875,0) arc (90:205.8:1.875cm and 3.875cm);
    % convenctie zone
    \draw (2,0,0) arc (0:116.5:2cm and -1cm);
    \draw (2,0,0) arc (0:90:2cm and 2cm);
    \draw (0,2,0) arc (90:206.5:1cm and 2cm);
    % radiatie zone
    \draw (1,0,0) arc (0:116.5:1cm and -0.5cm);
    \draw (1,0,0) arc (0:90:1cm and 1cm);
    \draw (0,1,0) arc (90:206.5:0.5cm and 1cm);
    % fill
    \draw[fill=blue] (4,0,0) arc (0:90:4cm and 4cm) -- (0,3.875,0) arc (90:0:3.875cm and 3.875cm) -- (4,0,0);
    \draw[fill=blue!70] (3.875,0,0) arc (0:90:3.875cm and 3.875cm) -- (0,2,0) arc (90:0:2cm and 2cm) -- (3.875,0,0);
    \draw[fill=blue!40] (2,0,0) arc (0:90:2cm and 2cm) -- (0,1,0) arc (90:0:1cm and 1cm) -- (2,0,0);
    \draw[fill=blue!10] (1,0,0) arc (0:90:1cm and 1cm) -- (0,0,0) -- (1,0,0);
    \draw[fill=green] (4,0,0) arc (0:116.5:4cm and -2cm) -- (0,0,3.875) arc (115.8:0:3.7cm and -1.65cm) -- (4,0,0);
    \draw[fill=green!70] (3.875,0,0) arc (0:115.8:3.875cm and -1.875cm) -- (0,0,2) arc (115.8:0:.96cm and -.865cm) -- (3.875,0,0);
    \draw[fill=green!40] (2,0,0) arc (0:116.5:2cm and -1cm) -- (0,0,1) arc (115.8:0:.96cm and -.43cm) -- (2,0,0);
    \draw[fill=green!10] (1,0,0) arc (0:116.5:1cm and -.5cm) -- (0,0,0) -- (1,0,0);
    \draw[fill=magenta] (0,4,0) arc (90:206.5:2cm and 4cm) -- (0,0,3.875) arc (206.5:90:1.65cm and 3.7cm) -- (0,4,0);
    \draw[fill=magenta!70] (0,3.875,0) arc (90:205.8:1.875cm and 3.875cm) -- (0,0,2) arc (205.8:90:.86cm and 1.925cm) -- (0,3.875,0);
    \draw[fill=magenta!40] (0,2,0) arc (90:206.5:1cm and 2cm) -- (0,0,1) arc (206.5:90:.43cm and .96cm) -- (0,2,0);
    \draw[fill=magenta!10] (0,1,0) arc (90:206.5:.5cm and 1cm) -- (0,0,0) -- (0,1,0);
\end{tikzpicture}
\end{document}

相关内容