質問

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!

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top