1

This is a question for an issue I have run into while writing code. Assume that I have three points $A=[\cos\alpha,\sin\alpha]$, $B=[\cos\beta,\sin\beta]$, and $C=[\cos\gamma,\sin\gamma]$ on a unit circle. Further assume that $B$ and $C$ are fixed, but that the point $A$ can be moved around the circle's circumference.

Now my question: What conditions can I check efficiently to ensure that $A$ is not moved outside the arc between $B$ and $C$ originally containing it?

As a point of clarification: I do not just wish to detect whether the point is on this arc or not, but I seek some quantifiable conditions (e.g., distance along the circumference or differences in angles) which allow me to detect when point A is moved outside this arc. I have sketched three setups to illustrate what I mean:

enter image description here

where I wish to restrict A to the red arcs. Here are two conditions I considered, but found problematic to implement:

  1. Limit point A's angle $\alpha$ in radians between the angles $\beta$ and $\gamma$. Unfortunately, this naive case only works in scenario (a) above. If the arc to which A is restricted crosses the (in my case, western) discontinuity from +pi/-pi, a naive upper and lower bound won't work.
  2. Calculate the arc length between $A$ and $B$ and between $A$ and $C$, then ensure that the sum of these lengths does not change as $A$ is moved. Unfortunately, while solutions such as this one provide a way to calculate this distance, it always returns the shorter distance. In scenario (c) above, however, this would not give us the correct arc between $A$ and $B$.
J.Galt
  • 961
  • 1
    If $\overline{BC}$ isn't a diameter, you can leverage the Inscribed Angle Theorem. On one arc, $\angle BAC$ is acute, on the other, $\angle BAC$ is obtuse; so, you can check the sign of the cosine of the angle, which in turn means simply checking the sign of the dot product $\overrightarrow{AB}\cdot\overrightarrow{AC}$. Thus, if $A_0$ is $A$'s initial position, then $(\overrightarrow{A_0B}\cdot\overrightarrow{A_0C})(\overrightarrow{AB}\cdot\overrightarrow{AC})$ will be negative if $A$ leaves the initial arc. – Blue May 08 '21 at 21:57
  • 1
    Alternatively, find the equation of $\overleftrightarrow{BC}$ in the form $px+qy+r=0$. Then the function $f(x,y)=px+qy+r$ is positive on one side of the line, and negative on the other. Thus, the test becomes to check the sign of $f(x_0,y_0)f(x,y)$ (where $(x_0,y_0)$ is the initial position of $A$); it's negative if $A$ moves outside the initial arc. ... This approach has the advantage that $\overline{BC}$ being a diameter is no longer an exceptional case. – Blue May 08 '21 at 22:09
  • 1
    Actually doing the math on the line equation option, the test becomes to check the sign of $$\sin\frac12(\alpha_0-\beta)\sin\frac12(\alpha_0-\gamma)\sin\frac12(\alpha-\beta)\sin\frac12(\alpha-\gamma)$$ The sign is negative when $A$ leaves the initial arc. (The inscribed angle/dot-product test gives almost the same criterion, except it has a factor of $\cos\frac12(\beta-\gamma)$, which is what makes diameters problematic.) – Blue May 08 '21 at 22:29
  • 1
    You may find the Wikipedia article Counterclockwise system to be helpful. – Somos May 08 '21 at 22:45

0 Answers0