Check two arcs intersect each other

circlesgeometry

I have two arcs defined with the following information:

Origin, Radius, StartPoint, EndPoint, StartAngle & EndAngle

The angles are signed so you know which direction around the circle the arc goes.

An arc inside an arc segment does not count as an overlap as the perimeters don't touch:

enter image description here

Is it possible to test if the two arcs intersect along their perimeters (I am not looking to test if the area of the circle segments overlap).

My current idea is using an algorithm to interpolate along the arcs as straight line segments and do line-line intersection tests for each line segment – which can be slow depending on how many line segments i use, but I am wondering if there is a more pure mathematical approach ?

Best Answer

One way to approach is this problem is to think circles rather than arcs:

First check if the two large circles intersect at all. This can be done by comparing the distance between the centers ($d$) with the sum of radii ($r_1 + r_2$). Let's suppose $r_1 \ge r_2$

  1. If $d > r_1 + r_2$ then the circles are outside each other and don't have any intersection points, and therefore neither do the arcs.

  2. If $d = r_1 + r_2$ then the circles are outside each other and touch at one point only, which is on the line connecting their centers.

  3. If $r_1 - r_2 < d < r_1 + r_2$ then the circles meet at two points.

  4. If $d = r_1 - r_2$ then the smaller circle is in the larger circle and touches it at only one point (analysis of the case where the radii are equal and the circles completely overlap is left as an exercise to the interested reader)

  5. If $d < r_1 - r_2$ then the smaller circle is in the larger circle and the two circles don't have any intersection points, therefore neither do the arcs.

Next, find the meeting points (if any) of the circles. This can be done by solving the system of equations of the two circles. This step gives up to 2 points.

Next, for each intersection point identified in the previous step, determine if it lies on the given arcs. This can be done through the following steps for each arc:

  1. Find the angle of that point with respect to the center of the arc.
  2. Compare the angle of the point (computed above) with the start and end angles of the arc. The point is on the given arc if its angle is between the start angle and end angle of the arc.

If the point of intersection of the circles is on both arcs then you have an answer.

Related Question