/** * Changes the direction of this line by setting it to the normalized value of the given vector. * * @param lineDirection new direction of this line. Not modified. */ default void setDirection(Vector3DReadOnly lineDirection) { getDirection().set(lineDirection); getDirection().normalize(); }
/** * Changes the direction of this line by setting it to the normalized values provided. * * @param lineDirectionX the new x-component of the direction of this line. * @param lineDirectionY the new y-component of the direction of this line. * @param lineDirectionZ the new z-component of the direction of this line. */ default void setDirection(double lineDirectionX, double lineDirectionY, double lineDirectionZ) { getDirection().set(lineDirectionX, lineDirectionY, lineDirectionZ); getDirection().normalize(); }
/** * Flips this line's direction. */ default void negateDirection() { getDirection().negate(); }
/** * Redefines this line such that it goes through the two given points. * * @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(Point3DReadOnly firstPointOnLine, Point3DReadOnly secondPointOnLine) { // checkDistinctPoints if (firstPointOnLine.equals(secondPointOnLine)) { throw new RuntimeException("Tried to create a line from two coincidal points"); } setPoint(firstPointOnLine); getDirection().sub(secondPointOnLine, firstPointOnLine); getDirection().normalize(); }
/** * 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 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(); }
/** * 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); }