If I create two paths in Quartz 2d, is there a way to determine if they intersect?
Vaguely thought one could make a context and set one path as the clipping path, then draw the other path through that; but then how to determine if the resultant path is 开发者_如何转开发empty?
I have had a similar problem to this. I was building an asteroids-like game, and needed to check for ship-asteroid and bullet-asteroid intersections. All 3 were drawn with vectors so worked out as simple as checking each line in one object against the lines in the other object. ie loop through the lines in one object and in that loop then loop through all potential object and their lines to see if there is an intersection.
To check for actual line intersection I would read up 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 get on.
精彩评论