diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f0ef73161..a50e33c54 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -73,6 +73,11 @@ Users are encouraged to upgrade to this version as this release not
2. A few methods in the FastMath class are in fact slower that their
counterpart in either Math or StrictMath (cf. MATH-740 and MATH-901).
">
+
+ "MonotoneChain" failed to generate a convex hull if only a minimal hull
+ shall be created (includeCollinearPoints=false) and collinear hull points
+ were present in the input.
+
Improve performance of "KolmogorovSmirnovTest#kolmogorovSmirnovTest(...)" for
large samples.
diff --git a/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/hull/MonotoneChain.java b/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/hull/MonotoneChain.java
index 2ade7a69e..50fd6b752 100644
--- a/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/hull/MonotoneChain.java
+++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/hull/MonotoneChain.java
@@ -160,8 +160,8 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
} else {
if (distanceToCurrent > distanceToLast) {
hull.remove(size - 1);
+ hull.add(point);
}
- hull.add(point);
}
return;
} else if (offset > 0) {
diff --git a/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java b/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
index c9e84ae70..4edebd9ac 100644
--- a/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
+++ b/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
@@ -53,6 +53,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Before
public void setUp() {
+ // by default, do not include collinear points
generator = createConvexHullGenerator(false);
random = new MersenneTwister(10);
}
@@ -203,6 +204,26 @@ public abstract class ConvexHullGenerator2DAbstractTest {
checkConvexHull(points, hull);
}
+ @Test
+ public void testCollinearPointOnExistingBoundary() {
+ // MATH-1135: check that collinear points on the hull are handled correctly
+ // when only a minimal hull shall be constructed
+ final Collection points = new ArrayList();
+ points.add(new Vector2D(7.3152, 34.7472));
+ points.add(new Vector2D(6.400799999999997, 34.747199999999985));
+ points.add(new Vector2D(5.486399999999997, 34.7472));
+ points.add(new Vector2D(4.876799999999999, 34.7472));
+ points.add(new Vector2D(4.876799999999999, 34.1376));
+ points.add(new Vector2D(4.876799999999999, 30.48));
+ points.add(new Vector2D(6.0959999999999965, 30.48));
+ points.add(new Vector2D(6.0959999999999965, 34.1376));
+ points.add(new Vector2D(7.315199999999996, 34.1376));
+ points.add(new Vector2D(7.3152, 30.48));
+
+ final ConvexHull2D hull = createConvexHullGenerator(false).generate(points);
+ checkConvexHull(points, hull);
+ }
+
@Test
public void testIssue1123() {