Prologue: I have very moderate knowledge of mathematics (highschool sophomore level). Any explanation needs to be broken down to chewable bits. I'm sorry if this inconveniences you guys.
I have the following problem: How do I find out if a circle and an arc sector of another circle intersect?
The small circles above are examples. The ones in red are the ones that do not intersect, the ones in green are that ones that do intersect.
This is my approach, based on immediate data that I have available about the arc sector and the other circle:
let $A$ be the arc sector of a circle defined as follows:
- $C$ $(Cx, Cy)$ is the centre of the circle.
- $D$ is a radius of the circle, of which we know the length. ($D$ stands for direction).
- $\alpha$ the angle of arc sector, so that $D$ bisects $\alpha$
We also know the point where $D$ intercepts the circle (not named in the drawing above)
\begin{equation} \\ \end{equation}
For the smaller circles:
let $P$ be a circle, defined as follows:
- $c$ $(cx, cy)$ is the centre of the circle.
- $r$ is the radius of the circle.
First, i check if $P$ is inside or intersects the circle defined by $C$ and $D$:
$$(D + r)^2 \geq (Cx - cx)^2 + (Cy - cy)^2$$ (sum of the radii squared is greater than or equal to the squared distance between $C$ and $c$)
Secondly, if the above is true, my plan is to find the angle between the radius $D$ and each of the two tangents to circle $P$ (there's a problem here, read bellow) that pass through $C$; if any of these two angles is equal to or smaller than $\frac{\alpha}{2}$, then I have an intersection.
Note: The problem with this approach is that it doesn't work in case $C$ is inside $P$ (like the small green circle that contains C in figure 1). I disregard this case, because I don't know how to deal with it. In short, I know my answer is wrong, I'm just letting you know what I have so far. Considering that the set of arguments of my function that will result in $P$ containing $C$ is almost negligible, a result where those cases are excluded is acceptable, even if not ideal.
I know how to find the angle between $Cc$ and the tangents:
$$\measuredangle uCc = \measuredangle vCc = \arcsin(\frac{r}{d})$$
But I think that's irrelevant.
What I need is to find the angle between each of the tangents (the black lines) and $D$, and if such angle is equal to or lesser than $\frac{\alpha}{2}$, then it's a hit, otherwise, a miss.
I think I need to find the slopes of the lines $Cu$ and $Cv$, so I can compare it to the slope of $D$ to find the angle between those lines, using the relation:
$$\tan(\theta) = \left| \frac{m_{a} - m_{b}}{1 + m_{a}m_{b}}\right|$$
For me to find the slopes of those lines, I think I need to know the points $u$ and $v$.
There's one last problem with my approach: the function $arctan$ (which I would use to find $\theta$, given $\tan(\theta)$) can give me wrong results in case one of the circles is in a position inside the opposite arc $A'$ formed by extending $D$ and the legs of the arc into diameters. I hear $arctan2$ can fix this, but I'm not sure how to use it.
If there's an easier solution than mine, it's very welcome. As I mentioned, the third point of the triangle is necessary for me to know how to solve this according to my approach so far. If there's a better and faster way, please let me know, since this problem is to be used in a computational algorithm.


