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

  • It is on the ray from the focus to other ray. – dustin Jun 7 '13 at 19:36
  • 1
    Hmm, in general two points are not enough to describe a unique arc: \draw (0,0) arc (135:45:2.828); \draw (0,0) arc (180:0:2); \draw (0,0) arc (190:350:2.032); – Tom Bombadil Jun 7 '13 at 19:39
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}
| improve this answer | |
  • There was a typo the second -\b should have been \b – dustin Jun 7 '13 at 20:05
  • @dustin: I've edited my answer. – Jake Jun 7 '13 at 20:20
  • Can you explain the code some since I don't understand. It works but I would like a better understanding. For instance, you defined \p1 = #2, \n1 = ..., what is \x1 ..., \y1 ... etc. – dustin Jun 7 '13 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.