You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are several ways to determine whether a point is inside polygon.
See wiki
Also, bounding box could used.
Roughly, the following methods could be applied:
The axis-aligned minimum bounding box (or AABB) bounding box
Object oriented minimum bounding box( OBB) see tutorial
Ray-casting
4.Winding number algorithm (more precise but costly)
5.Just let the GPU do all the work for you.Use glReadPixel()
Create a painting surface that is off screen (so you can paint into it, without it appearing anywhere on the screen). Fill it completely with the color black. Now let OpenGL paint your polygon (or even all of your polygons if you just want to test if the point is within any of them, but you don't care for which one) into this drawing surface and fill the polygon(s) with a different color, e.g. white. To check if a point is within the polygon, get the color of this point from the drawing surface. This is just a O(1) memory fetch. If it's white, it's inside, if it's black, it's outside. Easy, isn't it? This method will pay off if you have very little polygons (e.g. 50-100), but a damn lot of points to test (> 1000), in which case this method is much speedier than anything else.
The text was updated successfully, but these errors were encountered:
There are several ways to determine whether a point is inside polygon.
See wiki
Also, bounding box could used.
Roughly, the following methods could be applied:
The axis-aligned minimum bounding box (or AABB) bounding box
Object oriented minimum bounding box( OBB) see tutorial
Ray-casting
4.Winding number algorithm (more precise but costly)
5.Just let the GPU do all the work for you.Use glReadPixel()
The text was updated successfully, but these errors were encountered: