How to determine if two paths intersect in Quartz 2d?

If I create two paths in Quartz 2d, is there a way to determine if they intersect?

Vaguely thought that it was possible to create a context and set one path as a clipping path, and then draw another path through it; but then how to determine if the resulting path is empty?

+3
source share
1 answer

I had a similar problem. I was building an asteroid game, and I needed to check the intersection of the asteroids of ships and asteroids. All 3 were drawn with vectors that were as simple as checking each line in one object against lines in another object. those. loop through the lines in one object and in this loop, then sweep across the entire potential object and their lines to see if there is an intersection.

To check the actual line intersection, I would read here: http://zonalandeducation.com/mmts/intersections/intersectionOfTwoLines1/intersectionOfTwoLines1.html and here: http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=geometry2

Let us know how you are doing.

+1
source

Source: https://habr.com/ru/post/1759607/


All Articles