Jump to content

  • Log In with Google      Sign In   
  • Create Account


How do I detect if an object is inside or outside a polygon


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Codespike   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 October 2001 - 02:52 PM

Imagine an n-sided polygon, does anyone know a general formula I can apply to detect if an object is within the polygon''s boundaries or outside? What I intend to use it for is to detect whether my mouse cursor is within a polygon or not.

Sponsor:

#2 Oluseyi   Staff Emeritus   -  Reputation: 1678

Like
Likes
Like

Posted 08 October 2001 - 03:03 PM

These things are called "inside tests". I posted on two methods a few moths ago; try searching on that term. If you don''t find anything, I''ll dig up the info and post again.

Hint: the two major methods are winding numbers and intersection count.

#3 grhodes_at_work   Moderators   -  Reputation: 1361

Like
Likes
Like

Posted 09 October 2001 - 03:19 AM

A good web site for point-in-polygon tests:

http://www.acm.org/pubs/tog/editors/erich/ptinpoly/

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

#4 IStrikerI   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 October 2001 - 02:51 AM

i know two methods:

1. calculate a plane for each egde of the polygon and test the point against them.

2. imagine a point where you know it IS outside of the polygon. then draw a line from the point you want to check to the point which lies outside the polygon. if this line crossed one edge the point is inside the polygon. if it crossed two edges the point is outside the polygon. if it crossed three edges the point is inside the polygon and so on. this also works for non convex polygons.
i read this at gamasutra.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS