Repository: commons-math
Updated Branches:
  refs/heads/master cfe050299 -> c965f1c7f


MATH-1450: fixing PolygonsSet to return correct last vertex for open loops


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/73f3e2b3
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/73f3e2b3
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/73f3e2b3

Branch: refs/heads/master
Commit: 73f3e2b3d6b3f4a7000187bb3e6a4d82b118d3b9
Parents: cfe0502
Author: darkma773r <matt.juntu...@hotmail.com>
Authored: Sat Feb 10 23:44:16 2018 -0500
Committer: darkma773r <matt.juntu...@hotmail.com>
Committed: Sat Feb 10 23:44:16 2018 -0500

----------------------------------------------------------------------
 .../commons/math4/geometry/euclidean/twod/PolygonsSet.java       | 4 +---
 .../commons/math4/geometry/euclidean/twod/PolygonsSetTest.java   | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/73f3e2b3/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
 
b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
index 9b20b0c..d69b734 100644
--- 
a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
+++ 
b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
@@ -689,9 +689,7 @@ public class PolygonsSet extends 
AbstractRegion<Euclidean2D, Euclidean1D> {
                             if (j < (array.length - 1)) {
                                 // current point
                                 array[j++] = segment.getEnd();
-                            }
-
-                            if (j == (array.length - 1)) {
+                            } else if (j == (array.length - 1)) {
                                 // last dummy point
                                 double x = 
segment.getLine().toSubSpace(segment.getStart()).getX();
                                 x += FastMath.max(1.0, FastMath.abs(x / 2));

http://git-wip-us.apache.org/repos/asf/commons-math/blob/73f3e2b3/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
index 94a7157..d2f9bc0 100644
--- 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
+++ 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSetTest.java
@@ -191,7 +191,7 @@ public class PolygonsSetTest {
         checkPointsEqual(new Cartesian2D(0, 1), loop[1], tolerance);
         checkPointsEqual(new Cartesian2D(0, 0), loop[2], tolerance);
         checkPointsEqual(new Cartesian2D(1, 0), loop[3], tolerance);
-        checkPointsEqual(new Cartesian2D(1, 0), loop[4], tolerance);
+        checkPointsEqual(new Cartesian2D(1, 1), loop[4], tolerance);
     }
 
     @Test

Reply via email to