/** * Calculates and returns the value of the cross product of this frame vector with {@code tuple}. * * @param tuple the second term in the cross product. Not modified. * @return the value of the cross product. */ default double cross(FrameTuple2DReadOnly tuple) { checkReferenceFrameMatch(tuple); return Vector2DReadOnly.super.cross(tuple); }
/** * 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()); }
/** * 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); }
assertEquals(0.0, solutionHandler.getFootstepAdjustment().length(), 1e-3);
/** * Tests on a per component basis, if this line 2D is exactly equal to {@code other}. * <p> * If the two lines have different frames, this method returns {@code false}. * </p> * * @param other the other line 2D to compare against this. Not modified. * @return {@code true} if the two lines are exactly equal component-wise and are expressed in * the same reference frame, {@code false} otherwise. */ default boolean equals(FrameLine2DReadOnly other) { if (other == null || getReferenceFrame() != other.getReferenceFrame()) return false; else return getPoint().equals(other.getPoint()) && getDirection().equals(other.getDirection()); } }
/** * Tests on a per-component basis on the point and vector if this line is equal to {@code other} * with the tolerance {@code epsilon}. This method will return {@code false} if the two lines are * physically the same but either the point or vector of each line is different. For instance, if * {@code this.point == other.point} and {@code this.direction == - other.direction}, the two * lines are physically the same but this method returns {@code false}. * <p> * If the two lines have different frames, this method returns {@code false}. * </p> * * @param other the query. Not modified. * @param epsilon the tolerance to use. * @return {@code true} if the two lines are equal and are expressed in the same reference frame, * {@code false} otherwise. */ default boolean epsilonEquals(FrameLine2DReadOnly other, double epsilon) { if (getReferenceFrame() != other.getReferenceFrame()) return false; if (!getPoint().epsilonEquals(other.getPoint(), epsilon)) return false; if (!getDirection().epsilonEquals(other.getDirection(), epsilon)) return false; return true; }
/** * 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); }
assertEquals(0.0, solutionHandler.getFootstepAdjustment().length(), 1e-3);
/** * 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()); }
/** * 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); }
/** * Calculates and returns the angle in radians from this frame vector to {@code other}. * <p> * The computed angle is in the range [-<i>pi</i>; <i>pi</i>]. * </p> * * @param other the other frame vector used to compute the angle. Not modified. * @return the value of the angle from this frame vector to {@code other}. * @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same frame as * {@code this}. */ default double angle(FrameVector2DReadOnly other) { checkReferenceFrameMatch(other); return Vector2DReadOnly.super.angle(other); }
assertEquals(0.0, solutionHandler.getFootstepAdjustment().length(), 1e-3);
/** * 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); }
/** * Calculates and returns the value of the dot product of this frame vector with {@code other}. * <p> * For instance, the dot product of two vectors p and q is defined as: <br> * p . q = ∑<sub>i=1:2</sub>(p<sub>i</sub> * q<sub>i</sub>) * </p> * * @param other the other frame vector used for the dot product. Not modified. * @return the value of the dot product. * @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same frame as * {@code this}. */ default double dot(FrameVector2DReadOnly other) { checkReferenceFrameMatch(other); return Vector2DReadOnly.super.dot(other); }
/** * 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); }
/** * Compares {@code this} to {@code other} to determine if the two frame vectors are geometrically * similar, i.e. the length of the distance between them is less than or equal to {@code epsilon}. * * @param other the frame vector to compare to. Not modified. * @param epsilon the tolerance of the comparison. * @return {@code true} if the two frame vectors represent the same geometry, {@code false} * otherwise. * @throws ReferenceFrameMismatchException if {@code other} is not expressed in the same reference * frame as {@code this}. */ default boolean geometricallyEquals(FrameVector2DReadOnly other, double epsilon) { checkReferenceFrameMatch(other); return Vector2DReadOnly.super.geometricallyEquals(other, epsilon); } }
/** * 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)); }
/** * Tests if the two given vectors are parallel given a tolerance on the angle between the two vector * axes in the range ]0; <i>pi</i>/2[. This method returns {@code true} if the two vectors are * parallel, whether they are pointing in the same direction or in opposite directions. * * <p> * Edge cases: * <ul> * <li>if the length of either vector is below {@link EuclidGeometryTools#ONE_TEN_MILLIONTH}, this * method fails and returns {@code false}. * </ul> * </p> * * @param firstVector the first vector. Not modified. * @param secondVector the second vector. Not modified. * @param angleEpsilon tolerance on the angle in radians. * @return {@code true} if the two vectors are parallel, {@code false} otherwise. * @throws ReferenceFrameMismatchException if the arguments are not all expressed in the same * reference frame. */ public static boolean areVector2DsParallel(FrameVector2DReadOnly firstVector, FrameVector2DReadOnly secondVector, double angleEpsilon) { firstVector.checkReferenceFrameMatch(secondVector); return EuclidGeometryTools.areVector2DsParallel(firstVector, secondVector, angleEpsilon); }