PlanningLocation { public double angleTo(PlanningLocation location) { double latitudeDifference = location.latitude - latitude; double longitudeDifference = location.longitude - longitude; return Math.atan2(latitudeDifference, longitudeDifference); } PlanningLocation(long id, double latitude, double longitude, DistanceMap travelDistanceMap); long getId(); long distanceTo(PlanningLocation location); double angleTo(PlanningLocation location); @Override String toString();  }
@Test void angle_from_depot_at_zero_should_be_atan2_of_latitude_longitude() { PlanningLocation center = locationAt(0, 0); assertThat(center.angleTo(locationAt(0, 1))).isZero(); assertThat(center.angleTo(locationAt(0, -1))).isEqualTo(Math.PI); assertThat(center.angleTo(locationAt(1, 0))).isEqualTo(Math.PI / 2); assertThat(center.angleTo(locationAt(-1, 0))).isEqualTo(-Math.PI / 2); assertThat(center.angleTo(locationAt(-Double.MIN_VALUE, -1))).isEqualTo(-Math.PI); assertThat(center.angleTo(locationAt(-0, 1))).isZero(); }
@Test void angle_from_depot_on_real_coordinates_should_be_atan2_of_latitude_longitude() { PlanningLocation depot = locationAt(1.77, -10.5); Offset<Double> offset = offset(0.05); assertThat(depot.angleTo(locationAt(1.76, -5))).isCloseTo(0, offset).isNegative(); assertThat(depot.angleTo(locationAt(100000, -1))).isCloseTo(Math.PI / 2, offset); }