Commit 43e052d4 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

issue#198: wrong distance computation for VPolygon.

parent 116fec10
......@@ -406,6 +406,7 @@ public class VPolygon extends Path2D.Double implements VShape {
PathIterator iterator = this.getPathIterator(null);
double[] first = null;
double[] last = new double[2];
double[] next = new double[2];
VPoint currentClosest;
......@@ -417,6 +418,10 @@ public class VPolygon extends Path2D.Double implements VShape {
last[0] = next[0];
last[1] = next[1];
if(first == null) {
first = new double[]{last[0], last[1]};
}
iterator.currentSegment(next);
currentClosest = GeometryUtils.closestToSegment(new VLine(last[0],
......@@ -430,6 +435,17 @@ public class VPolygon extends Path2D.Double implements VShape {
iterator.next();
}
// dont forget the last and first point!
if(first != null) {
currentClosest = GeometryUtils.closestToSegment(new VLine(next[0],
next[1], first[0], first[1]), point);
if (currentClosest.distance(point) < currentMinDistance) {
currentMinDistance = currentClosest.distance(point);
resultPoint = currentClosest;
}
}
return resultPoint;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment