Consider this code snippet:
\draw[-latex] let
\p0 = (P6),
\p1 = (P5),
\p2 = (P4),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {.75cm},
\n4 = {(\n2 + \n1) / 2}
in (P6) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
This comes from the code below (at the bottom):
\documentclass[convert = false]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, intersections, backgrounds, arrows}
\begin{document}
\tikzset{circle with radius/.style = {shape = circle, inner sep = 0pt,
outer sep = 0pt, minimum size = {2 * (#1)}}}
\begin{tikzpicture}[line join = round, line cap = round,
every label/.append style = {font = \scriptsize},
dot/.style = {inner sep = +0pt, shape = circle,
draw = black, label = {#1}},
small dot/.style = {minimum size = .05cm, dot = {#1}},
big dot/.style = {minimum size = .1cm, dot = {#1}},
]
\begin{scope}
%\clip ($(B) + (1.5, -2)$) rectangle ($(B) + (-3, 2)$);
\coordinate (O) at (0, 0);
\pgfmathsetmacro{\as}{3}
\pgfmathsetmacro{\bs}{2.25}
\pgfmathsetmacro{\c}{sqrt(\as^2 - \bs^2)}
\pgfmathsetmacro{\al}{3.75}
\pgfmathsetmacro{\bl}{2.9}
\pgfmathsetmacro{\cl}{sqrt(\al^2 - \bl^2)}
\pgfmathsetmacro{\xs}{abs(\c - \cl)}
\coordinate (O) at (0, 0);
\node[fill = black, big dot = {below left: \(F\)}] (F) at (\c, 0) {};
\path[name path global = line1] (\c, 0) -- ++(60:{\as} and \bs);
\path[name path global = line2] (\c, 0) -- ++(150:6cm);
\draw[name path global = ell1, blue] (O) ellipse
(\as cm and \bs cm);
\draw[name path global = ell2, red] (-\xs, 0)
ellipse (\al cm and \bl cm);
\path[name intersections = {of = line1 and ell1, by = P1}];
\node[fill = black, big dot = {right: \(A\)}] (A) at (P1) {};
\path[name intersections = {of = line2 and ell2, by = P2}];
\node[fill = black, big dot = {above: \(B\)}] (B) at (P2) {};
\begin{scope}[declare function = {doubleA = 5.8cm;},
]
\clip ($(A.center) + (1, 0)$) rectangle ($(B.center) + (0, 1)$);
\begin{pgfinterruptboundingbox}
\path let
\p1 = ($(A) - (F)$),
\p2 = ($(B) - (F)$),
\n1 = {veclen(\x1, \y1)},
\n2 = {veclen(\x2, \y2)}
in
(A) node[name path global = aCircle, circle with radius = doubleA-\n1]
{}
(B) node[name path global = bCircle, circle with radius = doubleA-\n2]
{}
(F) node[name path global = fCircle,
circle with radius = .5 * doubleA] {};
\tikzset{name intersections = {of = aCircle and bCircle, name = F'} }
\foreach \solA in {2} {
\path ($(F)!.5!(F'-\solA)$) coordinate (C'-\solA)
($(C'-\solA)!doubleA/2!(F)$) coordinate (xDir-\solA)
(F'-\solA) node[name path global/.expanded = f'Circle-\solA,
circle with radius = .5 * doubleA] {};
} %!?
\foreach \solA in {2} { %!?
\path[name intersections = {of = fCircle and f'Circle-\solA,
by = {yDir-\solA}}]
($(xDir-\solA)-(C'-\solA)$) coordinate (xDir'-\solA)
($(yDir-\solA)-(C'-\solA)$) coordinate (yDir'-\solA)
;
}
\end{pgfinterruptboundingbox}
\foreach \solA in {2}
\draw[x = (xDir'-\solA), y = (yDir'-\solA), name path global = traj]
(C'-\solA) circle [radius = 1];
\end{scope}
\path[name path = circ] (B) circle [radius = 1bp];
\draw[name intersections = {of = circ and traj}, -latex] (B) --
($(intersection-1)!1.25cm!(intersection-2)$) coordinate (P3);
\draw[name intersections = {of = circ and ell2}, -latex, red] (B) --
($(intersection-1)!2cm!(intersection-2)$) coordinate (P4);
\draw[-latex, name path = line3] (P3) -- (P4);
\draw[name path = line4] (B) -- ($(B)!2.1cm!-90:(F)$) coordinate (P5);
\path[name path = circ2] (P3) circle [radius = 1bp];
\path[name intersections = {of = circ2 and line3}, name path = line5]
(P3) -- ($(intersection-1)!2cm!(P3)$);
\path[name intersections = {of = line5 and line4, by = P6}];
\path[name intersections = {of = circ and traj}] (B) --
($(intersection-1)!1.5cm!(intersection-2)$) coordinate (P7);
\path[name intersections = {of = circ and ell2}] (B) --
($(intersection-1)!2.5cm!(intersection-2)$) coordinate (P8);
\draw[-latex] let
\p0 = (P6),
\p1 = (P5),
\p2 = (P4),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {.75cm},
\n4 = {(\n2 + \n1) / 2}
in (P6) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\end{scope}
\end{tikzpicture}
\end{document}
So in this draw command, I set 0th point as the focus, the 1st point as the starting angle line, and the 2nd point as the ending angle line. However, the TikZ picture arcs the opposite direction (see below):
So I then took \n2 = {2 * pi - atan2(..)}
which should be wedge not encircled with the arc but this generate this picture:
Those two arcs should theoretically add up to a full circle.
What is going wrong?
How can I get the command to arc to the correct distance?
If I compile both commands, we can see without a doubt they aren't adding up:
Edit 2:
Consider the image below:
As to why I used the code above as MWE, we can see that I have arcs in the same vicinity that had negative angles as well. I defined those arcs just as I did the one that posed a problem. Therefore, it appeared to be an issue with that area not negative angles.
For instance, gamma2 was defined focus, lower line, and upper line but it drew the arc without needing special treatment unlike the phi angle I asked here about.
Best Answer
The trigonometric functions in PGF use degrees, so you'll have to use
360
instead of2*pi
, and you'll have to deduct the full circle from the angle, not the other way round.This becomes clear if you make a minimal example and look at the angles. The
delta angle
of the arc is theend angle
minus thestart angle
. In your case, you have a delta angle that's larger than 180°, so you get the large arc. By subtracting a full circle from the end angle, the absolute value of the difference angle becomes smaller than 180°: