@Test public void isPointInArc180degStart0deg() { double radius = 300; double margin = 0.0; double start = 0; double rotation = AngleMath.PI; IVector2 center = Vector2.fromXY(-100, 500); IArc arc = Arc.createArc(center, radius, start, rotation); assertThat(CircleMath.isPointInArc(arc, center, margin)).isTrue(); assertThat(CircleMath.isPointInArc(arc, center.addNew(Vector2.fromXY(50, 50)), margin)).isTrue(); assertThat(CircleMath.isPointInArc(arc, center.addNew(Vector2.fromXY(-50, 50)), margin)).isTrue(); assertThat(CircleMath.isPointInArc(arc, center.addNew(Vector2.fromXY(-50, -50)), margin)).isFalse(); assertThat(CircleMath.isPointInArc(arc, center.addNew(Vector2.fromXY(50, -50)), margin)).isFalse(); assertOutsideCircle(arc); }
public static boolean isPointInArc(final IArc arc, final IVector2 point, double margin) { if (!CircleMath.isPointInCircle(arc, point, margin)) { return false; } if (arc.center().equals(point)) { return true; } IVector2 dir = point.subtractNew(arc.center()); double a = dir.getAngle(); double b = AngleMath.normalizeAngle(arc.getStartAngle() + (arc.getRotation() / 2.0)); return abs(AngleMath.difference(a, b)) < (abs(arc.getRotation()) / 2.0); }
CircleMath { public static boolean isPointInArc(final IArc arc, final IVector2 point, double margin) { if (!CircleMath.isPointInCircle(arc, point, margin)) { return false; } if (arc.center().equals(point)) { return true; } IVector2 dir = point.subtractNew(arc.center()); double a = dir.getAngle(); double b = AngleMath.normalizeAngle(arc.getStartAngle() + (arc.getRotation() / 2.0)); return abs(AngleMath.difference(a, b)) < (abs(arc.getRotation()) / 2.0); } }
CircleMath { public static boolean isPointInArc(final IArc arc, final IVector2 point, double margin) { if (!CircleMath.isPointInCircle(arc, point, margin)) { return false; } if (arc.center().equals(point)) { return true; } IVector2 dir = point.subtractNew(arc.center()); double a = dir.getAngle(); double b = AngleMath.normalizeAngle(arc.getStartAngle() + (arc.getRotation() / 2.0)); return abs(AngleMath.difference(a, b)) < (abs(arc.getRotation()) / 2.0); } @SuppressWarnings("unused") private  CircleMath(); }
CircleMath { public static boolean isPointInArc(final IArc arc, final IVector2 point, double margin) { if (!CircleMath.isPointInCircle(arc, point, margin)) { return false; } if (arc.center().equals(point)) { return true; } IVector2 dir = point.subtractNew(arc.center()); double a = dir.getAngle(); double b = AngleMath.normalizeAngle(arc.getStartAngle() + (arc.getRotation() / 2.0)); return abs(AngleMath.difference(a, b)) < (abs(arc.getRotation()) / 2.0); } @SuppressWarnings("unused") private  CircleMath(); static List<IVector2> tangentialIntersections(final ICircle circle, final IVector2 externalPoint); static List<IVector2> lineIntersections(final ICircular circle, final ILineBase line); static List<IVector2> circleIntersections(final ICircle firstCircle, final ICircle secondCircle); static IVector2 nearestPointOutsideCircle(final ICircular circle, final IVector2 point); static boolean isPointInCircle(ICircular circle, IVector2 point, double margin); static boolean isPointInArc(final IArc arc, final IVector2 point, double margin); static IVector2 nearestPointOutsideArc(final IArc arc, final IVector2 point); static Vector2 stepAlongCircle(final IVector2 current, final IVector2 center, final double angle); }
CircleMath { public static boolean isPointInArc(final IArc arc, final IVector2 point, double margin) { if (!CircleMath.isPointInCircle(arc, point, margin)) { return false; } if (arc.center().equals(point)) { return true; } IVector2 dir = point.subtractNew(arc.center()); double a = dir.getAngle(); double b = AngleMath.normalizeAngle(arc.getStartAngle() + (arc.getRotation() / 2.0)); return abs(AngleMath.difference(a, b)) < (abs(arc.getRotation()) / 2.0); } @SuppressWarnings("unused") private  CircleMath(); static List<IVector2> tangentialIntersections(final ICircle circle, final IVector2 externalPoint); static List<IVector2> lineIntersections(final ICircular circle, final ILineBase line); static List<IVector2> circleIntersections(final ICircle firstCircle, final ICircle secondCircle); static IVector2 nearestPointOutsideCircle(final ICircular circle, final IVector2 point); static boolean isPointInCircle(ICircular circle, IVector2 point, double margin); static boolean isPointInArc(final IArc arc, final IVector2 point, double margin); static IVector2 nearestPointOutsideArc(final IArc arc, final IVector2 point); static Vector2 stepAlongCircle(final IVector2 current, final IVector2 center, final double angle);  }