/** * Finds the index of the closest edge to the query. * * @param point the coordinates of the query. Not modified. * @param closestEdgeToPack the line segment used to store the result. Not modified. * @return whether this method succeeded or not. * @throws ReferenceFrameMismatchException if {@code closestEdgetoPack} and {@code this} are not * expressed in the same reference frame. * @see #getClosestEdge(Point2DReadOnly, LineSegment2DBasics) */ default boolean getClosestEdge(Point2DReadOnly point, FixedFrameLineSegment2DBasics closestEdgeToPack) { checkReferenceFrameMatch(closestEdgeToPack); return ConvexPolygon2DReadOnly.super.getClosestEdge(point, closestEdgeToPack); }
/** * Finds the index of the closest edge to the query. * * @param point the coordinates of the query. Not modified. * @param closestEdgeToPack the line segment used to store the result. Not modified. * @return whether this method succeeded or not. * @throws ReferenceFrameMismatchException if {@code point} and {@code this} are not expressed in * the same reference frame. * @see #getClosestEdge(Point2DReadOnly, LineSegment2DBasics) */ default boolean getClosestEdge(FramePoint2DReadOnly point, LineSegment2DBasics closestEdgeToPack) { checkReferenceFrameMatch(point); return ConvexPolygon2DReadOnly.super.getClosestEdge(point, closestEdgeToPack); }
/** * Finds the index of the closest edge to the query. * <p> * WARNING: This method generates garbage. * </p> * <p> * Edge cases: * <ul> * <li>If the polygon has one or no vertices, this method fails and returns {@code null}. * </ul> * </p> * * @param point the coordinates of the query. Not modified. * @return the line segment representing the closest edge or {@code null} if this method failed. * @throws OutdatedPolygonException if {@link ConvexPolygon2DBasics#update()} has not been called * since last time this polygon's vertices were edited. */ default LineSegment2DBasics getClosestEdgeCopy(Point2DReadOnly point) { LineSegment2D closestEdge = new LineSegment2D(); if (getClosestEdge(point, closestEdge)) return closestEdge; else return null; }
/** * Finds the index of the closest edge to the query. * * @param point the coordinates of the query. Not modified. * @param closestEdgeToPack the line segment used to store the result. Not modified. * @return whether this method succeeded or not. * @see #getClosestEdge(Point2DReadOnly, LineSegment2DBasics) */ default boolean getClosestEdge(Point2DReadOnly point, FrameLineSegment2DBasics closestEdgeToPack) { closestEdgeToPack.setReferenceFrame(getReferenceFrame()); return ConvexPolygon2DReadOnly.super.getClosestEdge(point, closestEdgeToPack); }
/** * Finds the index of the closest edge to the query. * * @param point the coordinates of the query. Not modified. * @param closestEdgeToPack the line segment used to store the result. Not modified. * @return whether this method succeeded or not. * @throws ReferenceFrameMismatchException if {@code point}, {@code closestEdgetoPack}, and * {@code this} are not expressed in the same reference frame. * @see #getClosestEdge(Point2DReadOnly, LineSegment2DBasics) */ default boolean getClosestEdge(FramePoint2DReadOnly point, FixedFrameLineSegment2DBasics closestEdgeToPack) { checkReferenceFrameMatch(point); checkReferenceFrameMatch(closestEdgeToPack); return ConvexPolygon2DReadOnly.super.getClosestEdge(point, closestEdgeToPack); }
/** * Finds the index of the closest edge to the query. * * @param point the coordinates of the query. Not modified. * @param closestEdgeToPack the line segment used to store the result. Not modified. * @return whether this method succeeded or not. * @throws ReferenceFrameMismatchException if {@code point} and {@code this} are not expressed in * the same reference frame. * @see #getClosestEdge(Point2DReadOnly, LineSegment2DBasics) */ default boolean getClosestEdge(FramePoint2DReadOnly point, FrameLineSegment2DBasics closestEdgeToPack) { checkReferenceFrameMatch(point); closestEdgeToPack.setReferenceFrame(getReferenceFrame()); return ConvexPolygon2DReadOnly.super.getClosestEdge(point, closestEdgeToPack); }