diff --git a/build.gradle.kts b/build.gradle.kts index 85356239c..a9d614c9d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { ihmc { group = "us.ihmc" - version = "0.14.0" + version = "0.14.1" vcsUrl = "https://github.com/ihmcrobotics/euclid" openSource = true diff --git a/src/geometry/java/us/ihmc/euclid/geometry/interfaces/ConvexPolygon2DReadOnly.java b/src/geometry/java/us/ihmc/euclid/geometry/interfaces/ConvexPolygon2DReadOnly.java index e7c6d9962..3ff443e08 100644 --- a/src/geometry/java/us/ihmc/euclid/geometry/interfaces/ConvexPolygon2DReadOnly.java +++ b/src/geometry/java/us/ihmc/euclid/geometry/interfaces/ConvexPolygon2DReadOnly.java @@ -513,7 +513,11 @@ default void getVerticesInClockwiseOrder(int startIndexInclusive, int endIndexIn *
  • if {@code numberOfVertices == 1}, this method returns whether the query and the single vertex * are exactly equal. *
  • if {@code numberOfVertices == 2}, this method returns whether the query is exactly on the - * polygons single edge. + * polygon single edge. + *
  • if the query is exactly equal to one of the polygon vertices, this method returns + * {@code true}. + *
  • if the query is exactly on one of the polygon's edges, the intent for this method is to + * return {@code true} but this scenario is highly sensitive to numerical error. * * * @param x the x-coordinate of the query. @@ -570,7 +574,11 @@ default boolean isPointInside(double x, double y, double epsilon) *
  • if {@code numberOfVertices == 1}, this method returns whether the query and the single vertex * are exactly equal. *
  • if {@code numberOfVertices == 2}, this method returns whether the query is exactly on the - * polygons single edge. + * polygon single edge. + *
  • if the query is exactly equal to one of the polygon vertices, this method returns + * {@code true}. + *
  • if the query is exactly on one of the polygon's edges, the intent for this method is to + * return {@code true} but this scenario is highly sensitive to numerical error. * * * @param point the query. Not modified. diff --git a/src/geometry/java/us/ihmc/euclid/geometry/tools/EuclidGeometryPolygonTools.java b/src/geometry/java/us/ihmc/euclid/geometry/tools/EuclidGeometryPolygonTools.java index b068549d3..b7149fd03 100644 --- a/src/geometry/java/us/ihmc/euclid/geometry/tools/EuclidGeometryPolygonTools.java +++ b/src/geometry/java/us/ihmc/euclid/geometry/tools/EuclidGeometryPolygonTools.java @@ -478,14 +478,17 @@ public static boolean edgeNormal(int edgeIndex, List * WARNING: This method assumes that the given vertices already form a convex polygon. *

    *

    - * It is equivalent to performing the test against the polygon shrunk by {@code Math.abs(epsilon)} - * if {@code epsilon < 0.0}, or against the polygon enlarged by {@code epsilon} if - * {@code epsilon > 0.0}. - *

    - *

    * Edge cases: *

    * * @param pointX the x-coordinate of the query. @@ -555,7 +558,7 @@ public static boolean isPoint2DInsideConvexPolygon2D(double pointX, double point return crossProduct == 0.0; } - if (!isPoint2DOnSideOfLine2D(pointX, pointY, edgeStart, edgeEnd, !clockwiseOrdered)) + if (isPoint2DOnSideOfLine2D(pointX, pointY, edgeStart, edgeEnd, clockwiseOrdered)) return false; for (int index = 1; index < numberOfVertices; index++) @@ -563,7 +566,7 @@ public static boolean isPoint2DInsideConvexPolygon2D(double pointX, double point edgeStart = edgeEnd; edgeEnd = convexPolygon2D.get(next(index, numberOfVertices)); - if (!isPoint2DOnSideOfLine2D(pointX, pointY, edgeStart, edgeEnd, !clockwiseOrdered)) + if (isPoint2DOnSideOfLine2D(pointX, pointY, edgeStart, edgeEnd, clockwiseOrdered)) return false; } @@ -576,20 +579,17 @@ public static boolean isPoint2DInsideConvexPolygon2D(double pointX, double point * WARNING: This method assumes that the given vertices already form a convex polygon. *

    *

    - * It is equivalent to performing the test against the polygon shrunk by {@code Math.abs(epsilon)} - * if {@code epsilon < 0.0}, or against the polygon enlarged by {@code epsilon} if - * {@code epsilon > 0.0}. - *

    - *

    * Edge cases: *

    * * @param point the coordinates of the query. Not modified. diff --git a/src/test/java/us/ihmc/euclid/geometry/ConvexPolygon2DBasicsTest.java b/src/test/java/us/ihmc/euclid/geometry/ConvexPolygon2DBasicsTest.java index 1e6df138c..7a0ff994c 100644 --- a/src/test/java/us/ihmc/euclid/geometry/ConvexPolygon2DBasicsTest.java +++ b/src/test/java/us/ihmc/euclid/geometry/ConvexPolygon2DBasicsTest.java @@ -585,6 +585,18 @@ public void testIsInside() boolean isInside = polygon.isPointInside(testPoint); assertTrue(isInside); + + Random random = new Random(435657); + + for (int i = 0; i < ITERATIONS; i++) + { // Testing that querying for one of the vertices it returns true + ConvexPolygon2D convexPolygon2D = EuclidGeometryRandomTools.nextConvexPolygon2D(random); + + for (Point2DReadOnly vertex : convexPolygon2D.getPolygonVerticesView()) + { + assertTrue(convexPolygon2D.isPointInside(vertex)); + } + } } @Test