Reputation: 54193
In Illustrator, you can drag a rectangle and it will select all objects in it. It does beyond a bounding box test since it ensures its touching an actual part of the polygon. How does it efficiently do this then? (A C or C++ implementation would be preferable)
Thanks
Upvotes: 1
Views: 257
Reputation: 215627
You could also just construct the intersection of the rectangle with the object (a function which programs like Illustrator already have for many other purposes) and check that it's non-empty. More efficient algorithms are available (see caf's answer), but mine has the one advantage that it requires no additional code.
Upvotes: 0
Reputation: 239361
If you want to check if any part of polygon P is within a rectangle R, then you can do this:
Upvotes: 3