/** * 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. * @param secondEndpointZ z-coordinate of the new second endpoint. */ default void setSecondEndpoint(double secondEndpointX, double secondEndpointY, double secondEndpointZ) { getSecondEndpoint().set(secondEndpointX, secondEndpointY, secondEndpointZ); }
/** * Changes the second endpoint of this line segment. * * @param secondEndpoint new second endpoint of this line segment. Not modified. */ default void setSecondEndpoint(Point3DReadOnly secondEndpoint) { getSecondEndpoint().set(secondEndpoint); }
/** * Transforms this line segment using the inverse of the given homogeneous transformation matrix. * * @param transform the transform to apply on the endpoints of this line segment. Not modified. */ @Override default void applyInverseTransform(Transform transform) { getFirstEndpoint().applyInverseTransform(transform); getSecondEndpoint().applyInverseTransform(transform); } }
/** * Sets both endpoints of this line segment to zero. */ @Override default void setToZero() { getFirstEndpoint().setToZero(); getSecondEndpoint().setToZero(); }
/** * 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 {@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. * * @param transform the transform to apply on the endpoints of this line segment. Not modified. */ @Override default void applyTransform(Transform transform) { getFirstEndpoint().applyTransform(transform); getSecondEndpoint().applyTransform(transform); }
/** * 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) { getFirstEndpoint().set(firstEndpoint); getSecondEndpoint().add(firstEndpoint, fromFirstToSecondEndpoint); }
/** * Translates this line segment by the given (x, y, z). * <p> * Note that the length and direction of this line segment remains unchanged. * </p> * * @param x the distance to translate this line along the x-axis. * @param y the distance to translate this line along the y-axis. * @param z the distance to translate this line along the z-axis. */ default void translate(double x, double y, double z) { getFirstEndpoint().add(x, y, z); getSecondEndpoint().add(x, y, z); }
/** * Swaps this line segment's endpoints. */ default void flipDirection() { double x = getFirstEndpointX(); double y = getFirstEndpointY(); double z = getFirstEndpointZ(); setFirstEndpoint(getSecondEndpoint()); setSecondEndpoint(x, y, z); }