如何填充由圆弧定义的形状?

如何填充由圆弧定义的形状?

我有三个相交的圆弧,我想填充交点内的区域。

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{figure}[htbp]
        \centering
        \begin{tikzpicture}[scale=3]
        \tikzstyle{intersection} = [draw, circle ,fill=darkgray, inner sep=0.4mm]
        \draw (0.95572,-0.29428)  arc (-19.41:18.41:1);
        \draw (0.9414, 0.33728) arc (226:254:1.5);
        \draw (1.58918, 0.04265) arc (102:122:2);
        \end{tikzpicture}
    \end{figure}
\end{document}

我想要的是这样的:

在此处输入图片描述

但是当我使用

\fill (0.95572,-0.29428)  arc (-19.41:18.41:1) (0.9414, 0.33728) arc (226:254:1.5) (1.58918, 0.04265) arc (102:122:2);

我明白了:

在此处输入图片描述

圆弧通过圆心填充,但我想要圆心的补集。我该怎么做?

我可以使用“黑客”来填充由交点定义的三角形,然后用白色填充圆弧来实现我的目标,但我非常怀疑这是一个通用的解决方案。

答案1

这是第一步:添加--。第二步是剪辑。这产生

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
    \begin{figure}[htbp]
        \centering
        \begin{tikzpicture}[scale=3]
        \tikzstyle{intersection} = [draw, circle ,fill=darkgray, inner sep=0.4mm]
        \draw[name path=path1] (0.95572,-0.29428)  arc (-19.41:18.41:1);
        \draw[name path=path2] (0.9414, 0.33728) arc (226:254:1.5);
        \draw[name path=path3] (1.58918, 0.04265) arc (102:122:2);
        \path[name intersections={of=path1 and path2,by=x12}];
        \path[name intersections={of=path2 and path3,by=x23}];
        \path[name intersections={of=path3 and path1,by=x31}];
        \begin{scope}
        \clip (x12)--(x23)--(x31)--cycle;
        \filldraw[draw=black,fill=blue] (0.95572,-0.29428)  arc (-19.41:18.41:1) -- (0.9414, 0.33728) arc
        (226:254:1.5)-- (1.58918, 0.04265) arc (102:122:2);
        \end{scope}
     \end{tikzpicture}
    \end{figure}
\end{document}

在此处输入图片描述

编辑:我只是把代码稍微缩短了一点,并改变了填充颜色,否则这就是原始代码。

答案2

在此处输入图片描述

backgrounds在和库的帮助下intersections

\documentclass[tikz, margin=3mm]{standalone}%{article}
%\usepackage{tikz}
\usetikzlibrary{backgrounds, intersections}

\begin{document}
%    \begin{figure}[htbp]
%        \centering
    \begin{tikzpicture}[scale=3]
% fill arcs and determine their names
\fill[white, name path=a]   (0.95572,-0.29428)  arc (-19.41:18.41:1);
\fill[white, name path=b]   (0.9414, 0.33728)   arc (226:254:1.5);
\fill[white, name path=c]   (1.58918, 0.04265)  arc (102:122:2);
% calculate intersections
\path[name intersections={of=a and b, by={ab}}] ;
\path[name intersections={of=a and c, by={ac}}] ;
\path[name intersections={of=b and c, by={bc}}] ;
% background fill
\scoped[on background layer]\fill[red] (ab) -- (ac) -- (bc) -- cycle; % color determine according to your wish
% drawing arcs agaib
\draw   (0.95572,-0.29428)  arc (-19.41:18.41:1);
\draw   (0.9414, 0.33728)   arc (226:254:1.5);
\draw   (1.58918, 0.04265) arc (102:122:2);
    \end{tikzpicture}
%    \end{figure}
\end{document}

相关内容