如何让圆弧精确地位于圆上?

如何让圆弧精确地位于圆上?

我创建了下图:

在此处输入图片描述

使用此片段:

\documentclass[a4paper,12pt]{article}


\usepackage{parskip}
\usepackage{amssymb}
\usepackage[fleqn]{amsmath}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{fadings}
\setlength{\mathindent}{0pt}
\usepackage{color}
\usepackage{fixltx2e}
\usepackage{pgfplots}
\usepackage{graphicx}
\newcommand{\func}[1]{\operatorname{#1}}
\newcommand{\var}[1]{\mathit{#1}}


\begin{document}

        \begin{center}
        \begin{tikzpicture}[scale=0.9]
          \draw[->] (-6,0) -- (5,0) node[right] {$x$};
          \draw[->] (-5,-1) -- (-5,5) node[above] {$y$};
          \draw (-2.5,1.5) circle (1cm) node[xshift=30, yshift=20] {$R_1$};

          \draw (1.5,3) circle (1.5cm) node[xshift=40, yshift=30] {$R_2$};

          \draw [decorate,decoration={brace}]
          (-5.2,1.5) -- (-5.2,2.5) node [black,midway, xshift=-0.4cm] 
          {\footnotesize \rotatebox{90}{$\exists x R_1\cap \exists x R_2$}};

          \draw[thick,purple] (-5,1.5) -- (-5,2.5);

          \fill[opacity=0.5, color=purple, path fading=east] (-5,1.5) rectangle (6,2.5);

          \fill[opacity=0.5, color=purple, path fading=west] (-5.3,1.5) rectangle (-5,2.5);


        \end{tikzpicture}
        \end{center}

\end{document}

现在考虑圆 R_2。我想用紫色标记圆内的颜色区域部分。
我计算了圆周与颜色区域边缘的交点,发现它是 (2.91,2.5)。所以我尝试添加一个圆弧。但效果并不好……

以下是补充内容:

\documentclass[a4paper,12pt]{article}


\usepackage{parskip}
\usepackage{amssymb}
\usepackage[fleqn]{amsmath}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{fadings}
\setlength{\mathindent}{0pt}
\usepackage{color}
\usepackage{fixltx2e}
\usepackage{pgfplots}
\usepackage{graphicx}
\newcommand{\func}[1]{\operatorname{#1}}
\newcommand{\var}[1]{\mathit{#1}}


\begin{document}

        \begin{center}
        \begin{tikzpicture}[scale=0.9]
          \draw[->] (-6,0) -- (5,0) node[right] {$x$};
          \draw[->] (-5,-1) -- (-5,5) node[above] {$y$};
          \draw (-2.5,1.5) circle (1cm) node[xshift=30, yshift=20] {$R_1$};

          \draw (1.5,3) circle (1.5cm) node[xshift=40, yshift=30] {$R_2$};

          \draw [decorate,decoration={brace}]
          (-5.2,1.5) -- (-5.2,2.5) node [black,midway, xshift=-0.4cm] 
          {\footnotesize \rotatebox{90}{$\exists x R_1\cap \exists x R_2$}};

          \draw[thick,purple] (-5,1.5) -- (-5,2.5);

          \fill[opacity=0.5, color=purple, path fading=east] (-5,1.5) rectangle (6,2.5);

          \fill[opacity=0.5, color=purple, path fading=west] (-5.3,1.5) rectangle (-5,2.5);
          % addition here!
          \draw[thick, color=purple] (2.91,2.5)  arc[radius = 1.5cm, start angle= 0, end angle= -140];
        \end{tikzpicture}
        \end{center}

\end{document}

此添加并未将圆弧精确地画在圆 R_2 上:

在此处输入图片描述

无论我使用什么值,我都无法让这个圆弧恰好位于圆的周长上……

我希望我的帖子足够清楚,因为我不是英语使用者。
提前谢谢。

答案1

你必须选择合适的弧度。但最简单的方法是剪辑

      % addition here!
      \begin{scope}
      \clip (-5,1.5) rectangle (6,2.5);
      \draw[thick, color=purple] (1.5,3) circle (1.5cm);
      \end{scope}

代码:

\documentclass[a4paper,12pt]{article}

%% why so many packages for a MWE?
\usepackage{parskip}
\usepackage{amssymb}
\usepackage[fleqn]{amsmath}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{fadings}
\setlength{\mathindent}{0pt}
\usepackage{color}
\usepackage{fixltx2e}
\usepackage{pgfplots}
\usepackage{graphicx}
\newcommand{\func}[1]{\operatorname{#1}}
\newcommand{\var}[1]{\mathit{#1}}


\begin{document}

        \begin{center}
        \begin{tikzpicture}[scale=0.9]
          \draw[->] (-6,0) -- (5,0) node[right] {$x$};
          \draw[->] (-5,-1) -- (-5,5) node[above] {$y$};
          \draw (-2.5,1.5) circle (1cm) node[xshift=30, yshift=20] {$R_1$};

          \draw (1.5,3) circle (1.5cm) node[xshift=40, yshift=30] {$R_2$};

          \draw [decorate,decoration={brace}]
          (-5.2,1.5) -- (-5.2,2.5) node [black,midway, xshift=-0.4cm]
          {\footnotesize \rotatebox{90}{$\exists x R_1\cap \exists x R_2$}};

          \draw[thick,purple] (-5,1.5) -- (-5,2.5);

          \fill[opacity=0.5, color=purple, path fading=east] (-5,1.5) rectangle (6,2.5);

          \fill[opacity=0.5, color=purple, path fading=west] (-5.3,1.5) rectangle (-5,2.5);
          % addition here!
          \begin{scope}
          \clip (-5,1.5) rectangle (6,2.5);
          \draw[thick, color=purple] (1.5,3) circle (1.5cm);
          \end{scope}
        \end{tikzpicture}
        \end{center}

\end{document}

在此处输入图片描述

使用 arc,类似

% addition here!
          \draw[thick, color=purple] (2.91,2.5)  arc[radius = 1.5cm, start angle= -20, end angle= -160];

应该给你圆上的弧。

答案2

使用带注释的直角三角形可以轻松计算出角度:

\documentclass[a4paper,12pt]{article}

\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{fadings}
\usetikzlibrary{decorations, decorations.pathreplacing}

\begin{document}

  \begin{center}
  \begin{tikzpicture}[scale=0.9]
    \draw[->] (-6,0) -- (5,0) node[right] {$x$};
    \draw[->] (-5,-1) -- (-5,5) node[above] {$y$};
    \draw (-2.5,1.5) circle (1cm) node[xshift=30, yshift=20] {$R_1$};

    \draw (1.5,3) circle (1.5cm) node[xshift=40, yshift=30] {$R_2$};

    \draw [decorate,decoration={brace}]
    (-5.2,1.5) -- (-5.2,2.5) node [black,midway, xshift=-0.4cm] 
    {\footnotesize \rotatebox{90}{$\exists x R_1\cap \exists x R_2$}};

    \draw[thick,purple] (-5,1.5) -- (-5,2.5);

    \fill[opacity=0.5, color=purple, path fading=east] (-5,1.5)
       rectangle (6,2.5);

    \fill[opacity=0.5, color=purple, path fading=west] (-5.3,1.5)
        rectangle (-5,2.5);
    % addition here!
    % \draw[thick, color=purple] (2.91,2.5)  arc[radius = 1.5cm, start
    %     angle= 0, end angle= -140];
    \pgfmathsetmacro\angle{acos(1/3)}
    \draw[thick, color=purple, radius=1.5cm]
      (1.5, 3) ++(270-\angle:1.5cm) coordinate (start)
      arc[start angle=270-\angle, end angle=270+\angle];

    \draw[thin, node font=\scriptsize]

      (1.5, 3) node[above] {acos(0.5/1.5)}
      -- node[right] {0.5} (1.5, 2.5)
      -- (start) -- node[above left] {1.5} cycle;
  \end{tikzpicture}
  \end{center}

\end{document}

结果

答案3

以下是如何在 Metapost 中实现更通用、更简单的剪辑方法。

在此处输入图片描述

(我省略了褪色和支撑,但只要再多花点功夫就可以添加它们。)

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

color purple; purple = 3/4 red + 1/4 blue;

path xx, yy, r[], band;

u = 1cm;
xx = (left -- 10 right) scaled u;
yy = (down --  5 up)    scaled u;
r1 = fullcircle scaled 2u shifted (2.5u,1.5u);
r2 = fullcircle scaled 3u shifted (6.5u,3u);

band = unitsquare xscaled 10u yscaled (ypart point 2 of r1 - ypart point 6 of r2) 
                  shifted (-1/4u, ypart point 6 of r2);

fill band withcolor .85[purple,white];
label.lft(btex $\exists x R_1 \cap \exists x R_2$ etex rotated 90, point 3.5 of band);

draw r1;        label.lrt(btex $R_1$ etex, point 7 of r1);
draw r2;        label.urt(btex $R_2$ etex, point 1 of r2);
drawarrow xx;   label.rt (btex $x$   etex, point 1 of xx);
drawarrow yy;   label.top(btex $y$   etex, point 1 of yy);

picture overlay;
overlay = image(
  drawoptions(withcolor purple);
  % draw r1; <--- you could add this one too if you wanted
  draw r2; 
  draw yy;
  drawoptions();
  );
clip overlay to band; draw overlay;

endfig;
end.

这种方法的优点是,只要移动任一圆,红色圆弧就会自动正确绘制,无需进行任何计算。

了解以下情况会很有帮助:在普通 MP 中,一条直线从点 0 开始到点 1,并且普通 MP 中的圆上有 8 个“点”,点 0 位于 3 点钟方向,如下所示:

在此处输入图片描述

相关内容