Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Polygon interact other polygon

by bart (Canon)
on Oct 24, 2004 at 21:12 UTC ( #402073=note: print w/replies, xml ) Need Help??

in reply to Polygon interact other polygon

There's a nice simple algorithm to check if a point is inside a polygon: the principle is this: draw a line from it to any point outside the polygon (for example with an X that is larger than any X for all the polygon vertices), and count how many edges it crosses. Iff this number is even, the point is outside of the polygon.

There are problematic cases where your test line goes straight through a vertex. You could think up an elaborate advanced scheme, taking the direction of the crossing into account, and counting such a crossing as +0.5 or -0.5 depending on its direction; or you could simply try again with a different line.

Combine this with tests on whether any edges from the polygons actually cross, and the basis is set.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://402073]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2023-09-27 12:21 GMT
Find Nodes?
    Voting Booth?

    No recent polls found