I've got a Polygon
:
I want to check if the Location of an Entity is inside this Polygon
.
As example x:5 and y:5, How can I make a check to see if this Coordinate is inside this Polygon (Java)?
in = inpolygon( xq , yq , xv , yv ) returns in indicating if the query points specified by xq and yq are inside or on the edge of the polygon area defined by xv and yv . [ in , on ] = inpolygon( xq , yq , xv , yv ) also returns on indicating if the query points are on the edge of the polygon area.
To determine the status of a point (xp,yp) consider a horizontal ray emanating from (xp,yp) and to the right. If the number of times this ray intersects the line segments making up the polygon is even then the point is outside the polygon.
If you create the polygon using the Polygon
class that is included with java use the contains()
method.
http://docs.oracle.com/javase/6/docs/api/java/awt/Polygon.html
Take a look at the method summary:
contains(int x, int y)
- Determines whether the specified coordinates are inside this Polygon
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With