/** * Changes the second endpoint of this line segment. * * @param secondEndpointX x-coordinate of the new second endpoint. * @param secondEndpointY y-coordinate of the new second endpoint. */ default void setSecondEndpoint(double secondEndpointX, double secondEndpointY) { getSecondEndpoint().set(secondEndpointX, secondEndpointY); }
/** * 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(); }
/** * 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); }
/** * 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(); }
/** * 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); } }
/** * Swaps this line segment's endpoints. */ default void flipDirection() { double x = getFirstEndpointX(); double y = getFirstEndpointY(); setFirstEndpoint(getSecondEndpoint()); setSecondEndpoint(x, y); }
/** * 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(Point3DReadOnly firstEndpoint, Vector3DReadOnly fromFirstToSecondEndpoint) { setFirstEndpoint(firstEndpoint); setSecondEndpoint(firstEndpoint); getSecondEndpoint().add(fromFirstToSecondEndpoint.getX(), fromFirstToSecondEndpoint.getY()); }
Point2DReadOnly[] closestEdgeEndpoints = {closestEdge.getFirstEndpoint(), closestEdge.getSecondEndpoint()}; assertEqualsInEitherOrder(closestEdgeEndpoints[0], closestEdgeEndpoints[1], pointThatDefinesThePolygon0, pointThatDefinesThePolygon1);
boolean isClosestVertexPartOfClosestEdge = false; Point2DReadOnly[] segmentVertices = {closestEdge.getFirstEndpoint(), closestEdge.getSecondEndpoint()};