Search code examples
geometry2dintersection

How can I test for intersection (overlap) of 2D 'ring parts' or 'ring sections'?


'Ring parts' are sections cut out of a ring.

Each 'ring part' is represented by a center point, and then some bounds relative to that center point.

Inner and outer distance bounds define a 2D ring, first of all, and then a pair of angular bounds define a start and end cut off around this ring. (I am specifying the angular bounds in the form of a start angle and then a sweep angle, but exactly what form this takes is not so important.)

How can I test for geometric intersection between two such 'ring parts', whilst keeping the code that tests for this as simple and robust as possible?

I tried an approach based on first detecting the various cases for intersection between rings, (i.e. initially ignoring the angular bounds) and then checking whether the intersecting part falls inside the angular bounds. I thought it might be possible to reduce the information needed about the intersecting part of the rings to angle extents, but I don't think this works in all cases.

I also thought about an initial step of cutting (or clipping) one ring part along the radial bound lines of the other. I think this might be a reasonable way to go, but clipping a shape with curved edges in itself starts to get a bit complicated.


Solution

  • Contour of a 'ring part' is composed of 4 parts {2 circular arcs and 2 line segments}.
    So, I guess, you can check the intersection step by step.

    i.e. checking "contour part vs contour part intersection". This becomes

    • "circular arc vs circular arc"
    • "circular arc vs line segments"
    • "line segment vs line segment"

    I guess you can solve all of them.

    Also, if you want to check "One is completely inside of the another" pattern, you'll be able to check it with "Is any corner point of one 'ring part' inside the another". (where, 'corner points' is end points of the contour parts. one 'ring part' has 4 corner points.)