At present, I encounter a line erasure scenario in my project. I hope to seek some suggestions from there. The following is to abstract the specific problem:
A two-dimensional region of m * n with many irregular curves, each of which is recorded in many points: [(x1, y1), (x2, y2), (x3, y3) ...], stored as arrays: array1, array2 ..., now there is a circle (x, y) with a radius r, I need to confirm whether the circle and these lines have intersections, and select the lines with intersections. In addition, the coordinates and radius of the circle are constantly changing, and the irregular curve is changing, but the change is not very fast, so I need to consider using cache to improve performance.
A pic to show the case:
Some of my thoughts: In fact, even if It traverse all the points once a time, the complexity is O(N), but here N is a bit big, and because the circle is changing in real time, so the performance is still relatively poor. I can choose to use a quadtree, but it is not a typical two-dimensional collision scenario, and I should also consider that the current storage method is not satisfied so that I need to do real-time synchronous update of two data structures, but the overall look should be better than the first method, but I don't know if this is the right way. In addition, I am thinking that there should be a better solution here.
are there any good ideas or relevant experiences to share? Thank you very much