6

I have created the following figure:

enter image description here

With this segment:

\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}

Now consider the circle R_2. I want to mark the part of it that inside the coloured area with purple.
I calculated the point in which the circle perimeter intersects with the edge of the coloured area, and found it to be (2.91,2.5). So I tried to add an arc. But that didn't go well...

Here's the addition:

\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}

This addition did not draw the arc exactly on the circle R_2:

enter image description here

No matter what values I used, I couldn't get this arc to sit exactly on the circle perimeter...

I hope my post is clear enough, since I'm not an English speaker.
Thanks in advanced.

Bernard
  • 271,350

3 Answers3

10

You have to choose proper angles for arc. But the easiest is to clip

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

Code:

\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}

enter image description here

With arc, some thing like

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

should give you the arc on circle.

7

The angles can easily be calculated by using the annotated rectangular triangle:

\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}

Result

Heiko Oberdiek
  • 271,626
0

Here's how to do the more general and simpler clipping approach in Metapost.

enter image description here

(I've left out the fading and the brace, but they could be added with a little more effort.)

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.

The advantage of this approach is that the red arc is automatically drawn correctly if either circle is moved, and no calculations are needed.

It helps to know that in plain MP a straight line starts at point 0 and goes to point 1, and there are 8 "points" on a circle in plain MP with point 0 at 3 o'clock, like this:

enter image description here

Thruston
  • 42,268