Question

i'm looking for a algorithm to test if a point is lying inside or outside of a polygon (in our case we're interested whether the point is lying outside of the minimum bounding box of a polygon). We had an idea to test if a segment of the point has even number of intersections with the mbb. But we have no idea how to convert this idea into a java-code.

we've already two arraylist of the mbb-points and of our testpoints. We also have an the loweleft, upperright corner of the mbb and the height and the width of the mbb.

so has someone an idea how to test this in java? thanks a lot!

Was it helpful?

Solution

Create a polygon object with your data. Use the contains method of that polygon object.

Here is the java api : http://docs.oracle.com/javase/7/docs/api/

As for algorithm, you should try connecting the points and generate equations of line. Store the lines in a list, and see if the point you are testing is on the bounds of those lines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top