/** * Gets the lowest y-coordinate value of the vertices composing this polygon. * * @return the minimum y-coordinate. * @throws OutdatedPolygonException if {@link ConvexPolygon2DBasics#update()} has not been called * since last time this polygon's vertices were edited. * @throws EmptyPolygonException if this polygon is empty when calling this method. */ default double getMinY() { return getBoundingBox().getMinY(); }
/** * Gets the highest x-coordinate value of the vertices composing this polygon. * * @return the maximum x-coordinate. * @throws OutdatedPolygonException if {@link ConvexPolygon2DBasics#update()} has not been called * since last time this polygon's vertices were edited. * @throws EmptyPolygonException if this polygon is empty when calling this method. */ default double getMaxX() { return getBoundingBox().getMaxX(); }
/** * Gets the lowest x-coordinate value of the vertices composing this polygon. * * @return the minimum x-coordinate. * @throws OutdatedPolygonException if {@link ConvexPolygon2DBasics#update()} has not been called * since last time this polygon's vertices were edited. * @throws EmptyPolygonException if this polygon is empty when calling this method. */ default double getMinX() { return getBoundingBox().getMinX(); }
/** * Gets the highest y-coordinate value of the vertices composing this polygon. * * @return the maximum y-coordinate. * @throws OutdatedPolygonException if {@link ConvexPolygon2DBasics#update()} has not been called * since last time this polygon's vertices were edited. * @throws EmptyPolygonException if this polygon is empty when calling this method. */ default double getMaxY() { return getBoundingBox().getMaxY(); }
/** * Gets the size along the x-axis of this polygon's bounding box. * * @return the range on the x-axis of the bounding box. * @throws OutdatedPolygonException if {@link ConvexPolygon2DBasics#update()} has not been called * since last time this polygon's vertices were edited. */ default double getBoundingBoxRangeX() { BoundingBox2DReadOnly boundingBox = getBoundingBox(); return boundingBox.getMaxX() - boundingBox.getMinX(); }
/** * Gets the size along the y-axis of this polygon's bounding box. * * @return the range on the y-axis of the bounding box. * @throws OutdatedPolygonException if {@link ConvexPolygon2DBasics#update()} has not been called * since last time this polygon's vertices were edited. */ default double getBoundingBoxRangeY() { BoundingBox2DReadOnly boundingBox = getBoundingBox(); return boundingBox.getMaxPoint().getY() - boundingBox.getMinPoint().getY(); }
/** * Check if the given polygon intersects this region projected onto the XY-plane. * * @param convexPolygon2d * @return true if the polygon intersects this PlanarRegion. */ public boolean isPolygonIntersecting(ConvexPolygon2DReadOnly convexPolygon2d) { BoundingBox2DReadOnly polygonBoundingBox = convexPolygon2d.getBoundingBox(); if (!boundingBox3dInWorld.intersectsInclusiveInXYPlane(polygonBoundingBox)) return false; // Instead of projecting all the polygons of this region onto the world XY-plane, // the given convex polygon is projected along the z-world axis to be snapped onto plane. ConvexPolygon2D projectedPolygon = projectPolygonVerticallyToRegion(convexPolygon2d); ConvexPolygon2D dummyPolygon = new ConvexPolygon2D(); // Now, just need to go through each polygon of this region and see there is at least one intersection for (int i = 0; i < getNumberOfConvexPolygons(); i++) { ConvexPolygon2D polygonToCheck = convexPolygons.get(i); boolean hasIntersection = convexPolygonTools.computeIntersectionOfPolygons(polygonToCheck, projectedPolygon, dummyPolygon); if (hasIntersection) return true; } // Did not find any intersection return false; }