如何选择正确的交叉路口序列?

如何选择正确的交叉路口序列?

我想填充磁盘和以下图表界定的形式之间的交集:

\documentclass[11pt]{report}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\draw[name path=k1,fill=blue!30] plot[smooth cycle] coordinates 
{(0,0) (1,1) (3,0) (5,1) (7,-1.5) (4,-3) (2,-2) (0,-1)};
\draw [name path=k2] (1,0) circle (2cm);
\draw [red,very thick,intersection segments={of=k1 and k2,sequence={L1}}];
\draw [blue,very thick,intersection segments={of=k1 and k2,sequence={L3}}];
\draw [green,very thick,intersection segments={of=k1 and k2,sequence={R3}}];
\draw [green,very thick,intersection segments={of=k1 and k2,sequence={R2}}];
\end{tikzpicture}
\end{document}

我无法选择正确的段来正确填充交叉点。

答案1

嗯,我不确定intersection segments是不是有点问题,因为添加了一些不应该存在的路径,这让这个过程变得比它应该的要难。或者可能只是很难使用。

看这里:

在此处输入图片描述

正如您所注意到的,我们可以这样做,L1--L0--R0但是这些线条会产生问题,因为如果没有它们,填充就会出现细孔(箭头指向的线条将不存在,下面的蓝色会略微可见),而有了它们,填充中间就会出现线条。两者都不理想。

因此,避免这种情况的一种方法是绘制其他交集,但以一种绘制你想要的最终结果的方式。我在这里绘制的部分实际上是蓝色部分

输出

在此处输入图片描述

代码

\documentclass[margin=10pt, tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17} % <--- latest version
\usepgfplotslibrary{fillbetween}

\begin{document}
\begin{tikzpicture}
    \draw[name path=k1,fill=orange!30] plot[smooth cycle] coordinates 
{(0,0) (1,1) (3,0) (5,1) (7,-1.5) (4,-3) (2,-2) (0,-1)};
    \draw[name path=k2] (1,0) circle (2cm);

    \fill[blue!30,draw=black,
        intersection segments={of=k1 and k2,sequence={L2--R3}}];
    
\end{tikzpicture}
\end{document}

答案2

如果我理解正确的话,您想要从下面获得结果(并且您的问题是重复的)。也许我不明白,因为您想要某些东西的交点!?-而且您根本没有使用PGFPlots或。fillbetween

\documentclass[tikz, border=1 cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (1,0) circle (2cm);
\draw plot[smooth cycle] coordinates 
{(0,0) (1,1) (3,0) (5,1) (7,-1.5) (4,-3) (2,-2) (0,-1)};
\clip (1,0) circle (2cm);
\fill[blue!30] plot[smooth cycle] coordinates 
{(0,0) (1,1) (3,0) (5,1) (7,-1.5) (4,-3) (2,-2) (0,-1)};
\end{tikzpicture}
\end{document}

路口已填

相关内容