Skip to content

Commit

Permalink
Merge branch 'release/0.14.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Bertrand committed May 6, 2020
2 parents a1e41a5 + ab62c3d commit 4a131ca
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,11 @@ default void getVerticesInClockwiseOrder(int startIndexInclusive, int endIndexIn
* <li>if {@code numberOfVertices == 1}, this method returns whether the query and the single vertex
* are exactly equal.
* <li>if {@code numberOfVertices == 2}, this method returns whether the query is exactly on the
* polygons single edge.
* polygon single edge.
* <li>if the query is exactly equal to one of the polygon vertices, this method returns
* {@code true}.
* <li>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.
* </ul>
*
* @param x the x-coordinate of the query.
Expand Down Expand Up @@ -570,7 +574,11 @@ default boolean isPointInside(double x, double y, double epsilon)
* <li>if {@code numberOfVertices == 1}, this method returns whether the query and the single vertex
* are exactly equal.
* <li>if {@code numberOfVertices == 2}, this method returns whether the query is exactly on the
* polygons single edge.
* polygon single edge.
* <li>if the query is exactly equal to one of the polygon vertices, this method returns
* {@code true}.
* <li>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.
* </ul>
*
* @param point the query. Not modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,17 @@ public static boolean edgeNormal(int edgeIndex, List<? extends Point2DReadOnly>
* WARNING: This method assumes that the given vertices already form a convex polygon.
* </p>
* <p>
* 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}.
* </p>
* <p>
* Edge cases:
* <ul>
* <li>if {@code numberOfVertices < 3}, this method returns {@code false}.
* <li>if {@code numberOfVertices == 0}, this method returns {@code false}.
* <li>if {@code numberOfVertices == 1}, this method returns whether the query and the single vertex
* are exactly equal.
* <li>if {@code numberOfVertices == 2}, this method returns whether the query is exactly on the
* polygon single edge.
* <li>if the query is exactly equal to one of the polygon vertices, this method returns
* {@code true}.
* <li>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.
* </ul>
*
* @param pointX the x-coordinate of the query.
Expand Down Expand Up @@ -555,15 +558,15 @@ 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++)
{
edgeStart = edgeEnd;
edgeEnd = convexPolygon2D.get(next(index, numberOfVertices));

if (!isPoint2DOnSideOfLine2D(pointX, pointY, edgeStart, edgeEnd, !clockwiseOrdered))
if (isPoint2DOnSideOfLine2D(pointX, pointY, edgeStart, edgeEnd, clockwiseOrdered))
return false;
}

Expand All @@ -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.
* </p>
* <p>
* 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}.
* </p>
* <p>
* Edge cases:
* <ul>
* <li>if {@code numberOfVertices == 0}, this method returns {@code false}.
* <li>if {@code numberOfVertices == 1}, this method returns {@code false} if {@code epsilon < 0} or
* if the query is at a distance from the polygon's only vertex that is greater than
* {@code epsilon}, returns {@code true} otherwise.
* <li>if {@code numberOfVertices == 2}, this method returns {@code false} if {@code epsilon < 0} or
* if the query is at a distance from the polygon's only edge that is greater than {@code epsilon},
* returns {@code true} otherwise.
* <li>if {@code numberOfVertices == 1}, this method returns whether the query and the single vertex
* are exactly equal.
* <li>if {@code numberOfVertices == 2}, this method returns whether the query is exactly on the
* polygon single edge.
* <li>if the query is exactly equal to one of the polygon vertices, this method returns
* {@code true}.
* <li>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.
* </ul>
*
* @param point the coordinates of the query. Not modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a131ca

Please sign in to comment.