6
$\begingroup$

I have made myself a simple script that determines if two arcs which have a width overlap:

enter image description here

Currently its quite slow and inefficient and was wondering if any one knows a more efficient mathematical solution to solve this?

My current setup to solve overlap is done with the following steps:

Find intersecting points of the 4 circles (inner and outer radius of both arcs). Check if the intersecting points is inside the angle range of the arcs.

Next i do 4 tests to determine if the ends of arcs overlap which is 4 line segments tested against the 4 arcs which represent the inner and outer ranges of the radius of the pieces.

Since i do this every frame this is a lot of calculations. I am wondering if any smart person here knows a simpler mathematical approach that might simplify my current solution.

My arcs are represented by StartAngle, EndAngle, Origin and MinRadius/MaxRadius.

Thanks.

$\endgroup$
3
  • $\begingroup$ If you can have the equations of the circles and the lines of an arc you can check every point inside that segment by calculating the the signs of placing the points values in the equations. It is not clear what you mean by slow - for modern computers this will be calculated in less than a millisecond. $\endgroup$
    – Moti
    Jun 22 at 6:46
  • $\begingroup$ Imagine your circular arcs are iron rails of a railway. Imagine that you introduce a certain sufficiently dense set of rail sleepers ; forget the rails and test using a double loop if any of the sleepers of the first arc intersects any of the sleepers of the second one using a classical algorithm. See here. $\endgroup$
    – Jean Marie
    Jun 23 at 19:41
  • 1
    $\begingroup$ That feels more like an algorithmic solution rather than a pure mathematical solution @JeanMarie I am looking for a more pure math solution to determine if they overlap. $\endgroup$
    – WDUK
    Jun 23 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.