/** * Changes the point through which this line has to go. * * @param pointOnLineX the new x-coordinate of the point on this line. * @param pointOnLineY the new y-coordinate of the point on this line. * @param pointOnLineZ the new z-coordinate of the point on this line. */ default void setPoint(double pointOnLineX, double pointOnLineY, double pointOnLineZ) { getPoint().set(pointOnLineX, pointOnLineY, pointOnLineZ); }
/** * Changes the point through which this line has to go. * * @param pointOnLine new point on this line. Not modified. */ default void setPoint(Point3DReadOnly pointOnLine) { getPoint().set(pointOnLine); }
/** * Translates this line by the given (x, y, z). * <p> * Note that this line's direction 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) { getPoint().add(x, y, z); }
/** * Sets the point and vector of this line to {@link Double#NaN}. After calling this method, this * line becomes invalid. A new valid point and valid vector will have to be set so this line is * again usable. */ @Override default void setToNaN() { getPoint().setToNaN(); getDirection().setToNaN(); }
/** * Sets the point and vector of this line to zero. After calling this method, this line becomes * invalid. A new valid point and valid vector will have to be set so this line is again usable. */ @Override default void setToZero() { getPoint().setToZero(); getDirection().setToZero(); }
/** * Transforms this line using the given homogeneous transformation matrix. * * @param transform the transform to apply on this line's point and vector. Not modified. */ @Override default void applyTransform(Transform transform) { getPoint().applyTransform(transform); getDirection().applyTransform(transform); }
/** * Transforms this line using the inverse of the given homogeneous transformation matrix. * * @param transform the transform to apply on this line's point and vector. Not modified. */ @Override default void applyInverseTransform(Transform transform) { getPoint().applyInverseTransform(transform); getDirection().applyInverseTransform(transform); } }
/** * Tests if this line contains {@link Double#NaN}. * * @return {@code true} if {@link #getPoint()} and/or {@link #getDirection()} contains {@link Double#NaN}, * {@code false} otherwise. */ @Override default boolean containsNaN() { return getPoint().containsNaN() || getDirection().containsNaN(); }
/** * Redefines this line with a new point and a new direction vector. * <p> * After calling this method this line is in the XY-plane. * </p> * * @param pointOnLine new point on this line. Not modified. * @param lineDirection new direction of this line. Not modified. */ default void set(Point2DReadOnly pointOnLine, Vector2DReadOnly lineDirection) { getPoint().set(pointOnLine, 0.0); getDirection().set(lineDirection, 0.0); }
/** * Sets this line to represent the same geometry as the given {@code other}. * * @param other the other line to copy. Not modified. */ default void set(Line3DReadOnly other) { getPoint().set(other.getPoint()); getDirection().set(other.getDirection()); }
/** * Sets this line to represent the same geometry as the given {@code line2DReadOnly}. * <p> * After calling this method this line is in the XY-plane. * </p> * * @param line2DReadOnly the other line to copy. Not modified. */ default void set(Line2DReadOnly line2DReadOnly) { getPoint().set(line2DReadOnly.getPoint(), 0.0); getDirection().set(line2DReadOnly.getDirection(), 0.0); }
/** * Redefines this line such that it goes through the two given points. * <p> * After calling this method this line is in the XY-plane. * </p> * * @param firstPointOnLine first point on this line. Not modified. * @param secondPointOnLine second point on this line. Not modified. * @throws RuntimeException if the two given points are exactly equal. */ default void set(Point2DReadOnly firstPointOnLine, Point2DReadOnly secondPointOnLine) { // checkDistinctPoints if (firstPointOnLine.equals(secondPointOnLine)) { throw new RuntimeException("Tried to create a line from two coincidal points"); } getPoint().set(firstPointOnLine, 0.0); getDirection().set(secondPointOnLine, 0.0); getDirection().subX(firstPointOnLine.getX()); getDirection().subY(firstPointOnLine.getY()); getDirection().normalize(); }