填充两条曲线之间的区域

填充两条曲线之间的区域

我想绘制下图:
在此处输入图片描述

为此,我使用了以下代码:

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw [rotate around={15.05:(6.07,0.75)}] (6.07,0.75) ellipse (1.11cm and 0.56cm);
\draw [rotate around={-13.74:(8.9,0.78)}] (8.9,0.78) ellipse (1.07cm and 0.53cm);
\draw  (4.58,2.02)-- (11,2);
\draw  (11,2)-- (10.48,-1);
\draw  (10.48,-1)-- (4,-1);
\draw  (4,-1)-- (4.58,2.02);
\draw [shift={(6.76,0.91)}] plot[domain=1.71:4.85,variable=\t]({1*0.43*cos(\t r)+0*0.43*sin(\t r)},{0*0.43*cos(\t r)+1*0.43*sin(\t r)});
\draw [shift={(8.25,0.9)}] plot[domain=-1.6:1.54,variable=\t]({1*0.42*cos(\t r)+0*0.42*sin(\t r)},{0*0.42*cos(\t r)+1*0.42*sin(\t r)});
\draw [rotate around={-3.74:(8.09,7.47)}] (8.09,7.47) ellipse (3.48cm and 1.89cm);
\draw [rotate around={13.37:(7.03,7.4)}] (7.03,7.4) ellipse (1.2cm and 0.59cm);
\draw [rotate around={-18.43:(8.48,7.38)}] (8.48,7.38) ellipse (1.23cm and 0.59cm);
\draw [->] (8.96,6.46) -- (8.8,1.62);
\draw [->] (6.7,6.38) -- (6.46,1.62);
\draw [->] (7.3,0.98) -- (7.76,0.98);


\draw (9.54,9.82) node {$M$};
\draw (6.8,7.3) node {$U_i$};
\draw (8.8,7.3) node {$U_j$};
\draw (6.24,4.34) node {$\psi_i$};
\draw (9.52,4.2) node {$\psi_j$};
\draw (8.94,-1.3) node {$\mathbf{R}^n$};
\draw (7.6,0) node {$\psi_j\circ \psi_i^{-1}$};

\end{tikzpicture}
\end{document}

它产生:
在此处输入图片描述

我怎样才能为该图形着色?

答案1

有两个基本技巧可让您填充由两条不同曲线/轮廓所包围的区域:

  1. 剪切一条曲线并填充另一条曲线;
  2. 使用even odd rule

还有两者的组合和其他可能性。本答案重点介绍可能性 1。然后是一个问题,如何循环使用曲线进行填充。在几种可能性中,本答案将利用use path在第一部分和insert path第二条路径中都要使用这个技巧。

第一条路径修改您的代码,例如为正确的区域添加阴影。

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\makeatletter % https://tex.stackexchange.com/a/38995/121799
\tikzset{
  use path/.code={\pgfsyssoftpath@setcurrentpath{#1}}
}
\makeatother

\pagestyle{empty}
\begin{document}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw [rotate around={15.05:(6.07,0.75)},save path=\pathA] (6.07,0.75) ellipse (1.11cm and 0.56cm);
\draw [rotate around={-13.74:(8.9,0.78)},save path=\pathB] (8.9,0.78) ellipse (1.07cm and 0.53cm);
\draw  (4.58,2.02)-- (11,2);
\draw  (11,2)-- (10.48,-1);
\draw  (10.48,-1)-- (4,-1);
\draw  (4,-1)-- (4.58,2.02);
\draw [shift={(6.76,0.91)}] plot[domain=1.71:4.85,variable=\t]({1*0.43*cos(\t r)+0*0.43*sin(\t r)},{0*0.43*cos(\t r)+1*0.43*sin(\t r)});
\draw [shift={(8.25,0.9)}] plot[domain=-1.6:1.54,variable=\t]({1*0.42*cos(\t r)+0*0.42*sin(\t r)},{0*0.42*cos(\t r)+1*0.42*sin(\t r)});
\draw [rotate around={-3.74:(8.09,7.47)}] (8.09,7.47) ellipse (3.48cm and 1.89cm);
\draw [save path=\pathC,rotate around={13.37:(7.03,7.4)}] (7.03,7.4) ellipse (1.2cm and 0.59cm);
\draw [save path=\pathD,rotate around={-18.43:(8.48,7.38)}] (8.48,7.38) ellipse (1.23cm and 0.59cm);
\draw [->] (8.96,6.46) -- (8.8,1.62);
\draw [->] (6.7,6.38) -- (6.46,1.62);
\draw [->] (7.3,0.98) -- (7.76,0.98);


\draw (9.54,9.82) node {$M$};
\draw (6.8,7.3) node {$U_i$};
\draw (8.8,7.3) node {$U_j$};
\draw (6.24,4.34) node {$\psi_i$};
\draw (9.52,4.2) node {$\psi_j$};
\draw (8.94,-1.3) node {$\mathbf{R}^n$};
\draw (7.6,0) node {$\psi_j\circ \psi_i^{-1}$};
\begin{scope}
\clip[use path=\pathA];
\path[fill=blue,shift={(6.76,0.91)}] plot[domain=1.71:4.85,variable=\t]({1*0.43*cos(\t r)+0*0.43*sin(\t r)},{0*0.43*cos(\t r)+1*0.43*sin(\t r)})
-- ++ (1,0) |- cycle;
\end{scope}
\begin{scope}
\clip[use path=\pathB];
\path[fill=blue,shift={(8.25,0.9)}] plot[domain=-1.6:1.54,variable=\t]({1*0.42*cos(\t r)+0*0.42*sin(\t r)},{0*0.42*cos(\t r)+1*0.42*sin(\t r)})
-- ++ (-1,0) |- cycle;
\end{scope}
\clip[use path=\pathC];
\fill[blue,use path=\pathD];
\end{tikzpicture}
\end{document}

在此处输入图片描述

但是,我想知道您是否愿意考虑使用一种可以产生类似图片的更简单的代码。优点包括更多的相对定位,这样您就可以移动完整的部分而不必重新设置所有坐标。

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,patterns}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle
45,x=1.0cm,y=1.0cm,standard ellipse around/.style args={#1 rotated by #2}{%
insert path={[rotate around={#2:#1}] #1 circle[x radius=1.2cm,y radius=0.6cm]}}]
  \begin{scope}[yshift=6.5cm]
    \draw (0,0) circle[x radius=3.5cm,y radius=1.9cm];
    \node at (2,2.3) {$M$};
    \draw (-0.7,-0.2) node[left] (Ui) {$U_i$}
     [standard ellipse around={(-0.7,-0.2) rotated by 15}];
    \draw (0.7,-0.2) node[right] (Uj) {$U_i$}
     [standard ellipse around={(0.7,-0.2) rotated by -15}];
    \clip[standard ellipse around={(0.7,-0.2) rotated by -15}];
    \path[pattern=north east lines, 
     standard ellipse around={(-0.7,-0.2) rotated by 15}];
  \end{scope}
  \begin{scope}[local bounding box=b]
    \begin{scope}[xshift=-4mm,local bounding box=bl]
      \draw[clip,standard ellipse around={(-1.2,0) rotated by 15}];
      \draw[pattern=north east lines,standard ellipse around={(0,0) rotated by -15}];
    \end{scope}
    \begin{scope}[xshift=4mm,local bounding box=br]
      \draw[clip,standard ellipse around={(1.2,0) rotated by -15}];
      \draw[pattern=north east lines,standard ellipse around={(0,0) rotated by 15}];
    \end{scope}
    \draw [->] (bl) -- (br) node[midway,below=8mm]{$\psi_j\circ \psi_i^{-1}$};
  \end{scope}
  \draw[->] ([yshift=-0.5cm]Ui.south) -- ([yshift=2mm]bl.north-|Ui.south)
   node[midway,left]{$\psi_i$};
  \draw[->] ([yshift=-0.5cm]Uj.south) -- ([yshift=2mm]br.north-|Uj.south)
   node[midway,right]{$\psi_j$};
  \draw ([xshift=-1.5cm,yshift=-1cm]b.south west)
   -- ([xshift=-1cm,yshift=1cm]b.north west)
   -- ([xshift=1.5cm,yshift=1cm]b.north east)
   -- ([xshift=1cm,yshift=-1cm]b.south east) -- cycle;
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容