/** * Changes the first endpoint of this line segment. * * @param firstEndpointX x-coordinate of the new first endpoint. * @param firstEndpointY y-coordinate of the new first endpoint. */ default void setFirstEndpoint(double firstEndpointX, double firstEndpointY) { getFirstEndpoint().set(firstEndpointX, firstEndpointY); }
/** * Sets both endpoints of this line segment to {@link Double#NaN}. After calling this method, this * line segment becomes invalid. A new pair of valid endpoints will have to be set so this line * segment is again usable. */ @Override default void setToNaN() { getFirstEndpoint().setToNaN(); getSecondEndpoint().setToNaN(); }
/** * Redefines this line segment with a new first endpoint and a vector going from the first to the * second endpoint. * * @param firstEndpoint new first endpoint. Not modified. * @param fromFirstToSecondEndpoint vector going from the first to the second endpoint. Not * modified. */ default void set(Point2DReadOnly firstEndpoint, Vector2DReadOnly fromFirstToSecondEndpoint) { getFirstEndpoint().set(firstEndpoint); getSecondEndpoint().add(firstEndpoint, fromFirstToSecondEndpoint); }
/** * Tests if this line segment contains {@link Double#NaN}. * * @return {@code true} if {@link #getFirstEndpoint()} and/or {@link #getSecondEndpoint()} contains * {@link Double#NaN}, {@code false} otherwise. */ @Override default boolean containsNaN() { return getFirstEndpoint().containsNaN() || getSecondEndpoint().containsNaN(); }
/** * Sets both endpoints of this line segment to zero. */ @Override default void setToZero() { getFirstEndpoint().setToZero(); getSecondEndpoint().setToZero(); }
/** * Transforms this line segment using the given homogeneous transformation matrix and project the * result onto the XY-plane. * * @param transform the transform to apply on this line segment's endpoints. Not modified. * @param checkIfTransformInXYPlane whether this method should assert that the rotation part of the * given transform represents a transformation in the XY plane. * @throws NotAMatrix2DException if {@code checkIfTransformInXYPlane == true} and the rotation part * of {@code transform} is not a transformation in the XY plane. */ default void applyTransform(Transform transform, boolean checkIfTransformInXYPlane) { getFirstEndpoint().applyTransform(transform, checkIfTransformInXYPlane); getSecondEndpoint().applyTransform(transform, checkIfTransformInXYPlane); }
/** * Transforms this line segment using the given homogeneous transformation matrix and project the * result onto the XY-plane. * * @param transform the transform to apply on this line segment's endpoints. Not modified. * @param checkIfTransformInXYPlane whether this method should assert that the rotation part of the * given transform represents a transformation in the XY plane. * @throws NotAMatrix2DException if {@code checkIfTransformInXYPlane == true} and the rotation part * of {@code transform} is not a transformation in the XY plane. */ default void applyInverseTransform(Transform transform, boolean checkIfTransformInXYPlane) { getFirstEndpoint().applyInverseTransform(transform, checkIfTransformInXYPlane); getSecondEndpoint().applyInverseTransform(transform, checkIfTransformInXYPlane); } }
Point2DReadOnly[] closestEdgeEndpoints = {closestEdge.getFirstEndpoint(), closestEdge.getSecondEndpoint()}; assertEqualsInEitherOrder(closestEdgeEndpoints[0], closestEdgeEndpoints[1], pointThatDefinesThePolygon0, pointThatDefinesThePolygon1);
boolean isClosestVertexPartOfClosestEdge = false; Point2DReadOnly[] segmentVertices = {closestEdge.getFirstEndpoint(), closestEdge.getSecondEndpoint()};