/** * Redefines this line with a new point, a new direction vector, and a new reference frame. * <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 setIncludingFrame(Point2DReadOnly pointOnLine, FrameVector2DReadOnly lineDirection) { setIncludingFrame(lineDirection.getReferenceFrame(), pointOnLine, lineDirection); }
/** * Redefines this line with a new point, a new direction vector, and a new reference frame. * * @param pointOnLine new point on this line. Not modified. * @param lineDirection new direction of this line. Not modified. */ default void setIncludingFrame(Point2DReadOnly pointOnLine, FrameVector2DReadOnly lineDirection) { setIncludingFrame(lineDirection.getReferenceFrame(), pointOnLine, lineDirection); }
/** * Redefines this line with a new point and a new direction vector. * * @param pointOnLine new point on this line. Not modified. * @param lineDirection new direction of this line. Not modified. * @throws ReferenceFrameMismatchException if {@code this} and {@code lineDirection} are not * expressed in the same reference frame. */ default void set(Point2DReadOnly pointOnLine, FrameVector2DReadOnly lineDirection) { set(lineDirection.getReferenceFrame(), pointOnLine, lineDirection); }
/** * 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. * @throws ReferenceFrameMismatchException if {@code this} and {@code lineDirection} are not * expressed in the same reference frame. */ default void set(Point2DReadOnly pointOnLine, FrameVector2DReadOnly lineDirection) { set(lineDirection.getReferenceFrame(), pointOnLine, lineDirection); }
/** * Asserts on a per component basis that the two frame vectors represent the same geometry to an * {@code epsilon}. * <p> * Note: the two arguments are considered to be equal if they are both equal to {@code null}. * </p> * * @param messagePrefix prefix to add to the automated message. * @param expected the expected frame vector. Not modified. * @param actual the actual frame vector. Not modified. * @param epsilon the tolerance to use. * @param format the format to use for printing each component when an {@code AssertionError} is * thrown. * @throws AssertionError if the two frame vectors do not represent the same geometry or not * expressed in the reference frame. If only one of the arguments is equal to * {@code null}. */ public static void assertFrameVector2DGeometricallyEquals(String messagePrefix, FrameVector2DReadOnly expected, FrameVector2DReadOnly actual, double epsilon, String format) { if (expected == null && actual == null) return; if (expected != null ^ actual != null) throwNotEqualAssertionError(messagePrefix, expected, actual, format); if (expected.getReferenceFrame() != actual.getReferenceFrame()) { throwNotEqualAssertionError(messagePrefix, expected, actual, format); } assertVector2DGeometricallyEquals(messagePrefix, expected, actual, epsilon, format); }
/** * Computes the vector perpendicular to the given {@code vector} such that: * <ul> * <li>{@code vector.dot(perpendicularVector) == 0.0}. * <li>{@code vector.angle(perpendicularVector) == Math.PI / 2.0}. * </ul> * <p> * WARNING: This method generates garbage. * </p> * * @param vector the vector to compute the perpendicular of. Not modified. * @return the perpendicular vector. * @throws ReferenceFrameMismatchException if the read-only arguments are not all expressed in the * same reference frame. */ public static FrameVector2D perpendicularVector2D(FrameVector2DReadOnly vector) { return new FrameVector2D(vector.getReferenceFrame(), EuclidGeometryTools.perpendicularVector2D(vector)); }
/** * Computes the vector perpendicular to the given {@code vector} such that: * <ul> * <li>{@code vector.dot(perpendicularVector) == 0.0}. * <li>{@code vector.angle(perpendicularVector) == Math.PI / 2.0}. * </ul> * * @param vector the vector to compute the perpendicular of. Not modified. * @param perpendicularVectorToPack a 2D vector in which the perpendicular vector is stored. * Modified. * @throws ReferenceFrameMismatchException if the arguments are not all expressed in the same * reference frame. */ public static void perpendicularVector2D(FrameVector2DReadOnly vector, FixedFrameVector2DBasics perpendicularVectorToPack) { perpendicularVectorToPack.set(vector.getReferenceFrame(), -vector.getY(), vector.getX()); }
/** * Computes the vector perpendicular to the given {@code vector} such that: * <ul> * <li>{@code vector.dot(perpendicularVector) == 0.0}. * <li>{@code vector.angle(perpendicularVector) == Math.PI / 2.0}. * </ul> * * @param vector the vector to compute the perpendicular of. Not modified. * @param perpendicularVectorToPack a 2D vector in which the perpendicular vector is stored. * Modified. * @throws ReferenceFrameMismatchException if the read-only arguments are not all expressed in the * same reference frame. */ public static void perpendicularVector2D(FrameVector2DReadOnly vector, FrameVector2DBasics perpendicularVectorToPack) { perpendicularVectorToPack.setToZero(vector.getReferenceFrame()); perpendicularVectorToPack.set(-vector.getY(), vector.getX()); }