@Test public void testAngleDifference() { final double maxAbsAngle = 2 * AngleMath.PI_TWO; for (double angle1 = -maxAbsAngle; angle1 < maxAbsAngle; angle1 += 0.1) { for (double angle2 = -maxAbsAngle; angle2 < maxAbsAngle; angle2 += 0.1) { IVector2 vector1 = Vector2.fromAngle(angle1); IVector2 vector2 = Vector2.fromAngle(angle2); double diff = AngleMath.difference(angle2, angle1); double diff1 = VectorMath.angleDifference(vector1, vector2).orElse(0.0); assertThat(diff).isCloseTo(diff1, within(1e-4)); assertThat(diff).isBetween(-AngleMath.PI, AngleMath.PI); } } }
static Optional<Double> angleDifference(IVector2 fromVector, IVector2 toVector) { if (toVector.isZeroVector() || fromVector.isZeroVector()) { return Optional.empty(); } return Optional.of(AngleMath.difference(toVector.getAngle(), fromVector.getAngle())); }
VectorMath { static Optional<Double> angleDifference(IVector2 fromVector, IVector2 toVector) { if (toVector.isZeroVector() || fromVector.isZeroVector()) { return Optional.empty(); } return Optional.of(AngleMath.difference(toVector.getAngle(), fromVector.getAngle())); } }
VectorMath { static Optional<Double> angleDifference(IVector2 fromVector, IVector2 toVector) { if (toVector.isZeroVector() || fromVector.isZeroVector()) { return Optional.empty(); } return Optional.of(AngleMath.difference(toVector.getAngle(), fromVector.getAngle())); } @SuppressWarnings("unused") private  VectorMath(); }
VectorMath { static Optional<Double> angleDifference(IVector2 fromVector, IVector2 toVector) { if (toVector.isZeroVector() || fromVector.isZeroVector()) { return Optional.empty(); } return Optional.of(AngleMath.difference(toVector.getAngle(), fromVector.getAngle())); } @SuppressWarnings("unused") private  VectorMath(); static double distancePP(final IVector2 a, final IVector2 b); static double distancePPSqr(final IVector2 a, final IVector2 b); }
VectorMath { static Optional<Double> angleDifference(IVector2 fromVector, IVector2 toVector) { if (toVector.isZeroVector() || fromVector.isZeroVector()) { return Optional.empty(); } return Optional.of(AngleMath.difference(toVector.getAngle(), fromVector.getAngle())); } @SuppressWarnings("unused") private  VectorMath(); static double distancePP(final IVector2 a, final IVector2 b); static double distancePPSqr(final IVector2 a, final IVector2 b);  }