I'm using the RegonFactory.intersection method to get the intersection of
polygons. However, I'm getting points that are outside of one of the
original polygons. See example below. Am I misinterpreting what the
intersection method does, miss-using it, or is this a bug?
Vector2D[][] vertices1 = new Vector2D[][] {
new Vector2D[] {
new Vector2D(-25.8907, 53.6079),
new Vector2D(-25.3586, 53.5214),
new Vector2D(-25.6256, 53.1507),
new Vector2D(-26.0395, 53.2562)
}
};
PolygonsSet set1 = buildSet(vertices1);
Vector2D[][] vertices2 = new Vector2D[][] {
new Vector2D[] {
new Vector2D(-25.7455, 53.3656),
new Vector2D(-25.3007, 53.2765),
new Vector2D(-25.4181, 52.9993),
new Vector2D(-25.9476, 53.0366)
}
};
PolygonsSet set2 = buildSet(vertices2);
PolygonsSet intersectionSet = (PolygonsSet) new
RegionFactory<Euclidean2D>().intersection(set1.copySelf(), set2.copySelf());
Vector2D[][] intersectionVerts = intersectionSet.getVertices();
for (Vector2D[] set : intersectionVerts) {
for (Vector2D vertex : set) {
System.out.println(vertex);
}
}
OUTPUT:
{-26.04; 53.26}
{-25.89; 53.61}
{-25.36; 53.52}
{-25.51; 53.32}
{-25.3; 53.28}
{-25.42; 53} <- OUTSIDE polygon A
{-25.72; 53.02} <- OUTSIDE polygon A
{-25.95; 53.04} <- OUTSIDE polygon A
{-25.84; 53.21}