4

Can an arc be drawn without using an angle but two locations?

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \pgfmathsetmacro{\a}{2.5}
  \pgfmathsetmacro{\b}{2}
  \pgfmathsetmacro{\c}{sqrt(\a^2 - \b^2)}
  \draw (0, 0) ellipse (\a cm and \b cm);
  \filldraw[black] (\c, 0) circle (.05cm) node[right = 2pt, scale = .75]
  {\(F\)};
  \begin{scope}[decoration = {markings,
      mark = at position 0.5 with {\node[circle, inner sep = .01cm,
        fill = white, scale = .75] {\(\mathbf{r}_1\)};},
    }]
    \draw[postaction = decorate]
    (\c , 0) -- ({\a * cos(90)}, {\b * sin(90)});
  \end{scope}
  \begin{scope}[decoration = {markings,
      mark = at position 0.5 with {\node[circle, inner sep = .01cm,
        fill = white, scale = .75] {\(\mathbf{r}_2\)};},
    }]
    \draw[postaction = decorate]
    (\c , 0) -- ({\a * cos(60)}, {-\b * sin(60)});
  \end{scope}
  \begin{scope}[decoration = {markings,
      mark = at position 0.5 with {\node[circle, inner sep = .01cm,
        fill = white, scale = .75] {\(2a - r_1\)};},
    }]
    \draw[postaction = decorate]
    (-\c , 0) -- ({\a * cos(90)}, {\b * sin(90)});
  \end{scope}
  \begin{scope}[decoration = {markings,
      mark = at position 0.5 with {\node[circle, inner sep = .01cm,
        fill = white, scale = .75] {\(2a - r_2\)};},
    }]
    \draw[postaction = decorate]
    (-\c , 0) -- ({\a * cos(60)}, {-\b * sin(60)});
  \end{scope}
  \filldraw[draw = black, fill = white] (-\c, 0) circle (.05cm)
  node[left = 2pt, scale = .75]
  {\(F^*\)};
  \filldraw[black] ({\a * cos(60)}, {-\b * sin(60)})
  node[below = 2pt, scale = .75] {\(P_2\)};
  \filldraw[black] ({\a * cos(90)}, {\b * sin(90)})
  node[above = 2pt, scale = .75] {\(P_1\)};
\end{tikzpicture}}
\end{document}

I want to draw an arc from ({\a * cos(60) / 4}, {-\b * sin(60) / 4}) to ({\a * cos(90) / 4}, {\b * sin(90) / 4}) without figuring out the angle (which is trivial to do but would like to let latex do the job).

How can this be done? If it can't, I can do the math then and get the job done myself.

enter image description here

dustin
  • 18,617
  • 23
  • 99
  • 204

1 Answers1

7

You can use one of the approaches from Label angle with tikz. Here, I've wrapped Shiyu's answer in a macro that takes the center point and two points on the rays as arguments, and draws the arc. It also takes an optional argument that can be used to set the draw options.

\def\angleRadius{0.5cm}
\newcommand{\markangle}[4][]{
    \draw[#1] let \p1=#2, \p2=#3, \p3=#4, 
         \n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
         ($(\p1)!\angleRadius!(\p3)$) arc [start angle=\n2-360, end angle=\n1, radius=\angleRadius]; 
}

I've simplified your code a bit, you don't need all those scopes and the markings decorations just to place nodes on lines:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\angleRadius{0.5cm}
\newcommand{\markangle}[4][]{
    \draw[#1] let \p1=#2, \p2=#3, \p3=#4, 
         \n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
         ($(\p1)!\angleRadius!(\p3)$) arc [start angle=\n2-360, end angle=\n1, radius=\angleRadius]; 
}


\begin{document}
\begin{tikzpicture}[
    radius=0.05cm
]
  \pgfmathsetmacro{\a}{2.5}
  \pgfmathsetmacro{\b}{2}
  \pgfmathsetmacro{\c}{sqrt(\a^2 - \b^2)}
  \draw (0, 0) ellipse [x radius=\a cm, y radius=\b cm];
  \filldraw[black] (\c, 0) circle node[right = 2pt, scale = .75]
  {$F$};
  \draw (\c,0) -- ({\a * cos(90)}, {\b * sin(90)})
    node [pos=0.5, fill=white, font=\small, inner sep=2pt] {$\mathbf{r}_1$};
  \draw (\c , 0) -- ({\a * cos(60)}, {-\b * sin(60)})
            node [pos=0.5, fill=white, font=\small, inner sep=2pt] {$\mathbf{r}_2$};;
  \draw (-\c , 0) -- ({\a * cos(90)}, {\b * sin(90)})
            node [pos=0.5, fill=white, font=\small, inner sep=2pt] {$2a - r_1$};;
  \draw (-\c , 0) -- ({\a * cos(60)}, {-\b * sin(60)})
            node [pos=0.5, fill=white, font=\small, inner sep=2pt] {$2a - r_2$};;
  \filldraw[draw = black, fill = white] (-\c, 0) circle
  node[left, font=\small] {\(F^*\)};
  \node at ({\a * cos(60)}, {-\b * sin(60)}) [below = 2pt, scale = .75] {\(P_2\)};
  \node at ({\a * cos(90)}, {\b * sin(90)}) [above = 2pt, scale = .75] {\(P_1\)};
  \markangle[thick, red]{(\c, 0)}{({\a * cos(60)}, {-\b * sin(60)})}{({\a * cos(90)}, {\b * sin(90)})}
\end{tikzpicture}
\end{document}
Jake
  • 232,450