Geo { public static double fastDistance(double lat1, double lon1, double lat2, double lon2) { final double lat1r = Math.toRadians(lat1); final double lat2r = Math.toRadians(lat2); final double delta_lon = Math.toRadians(lon2 - lon1); final double x = delta_lon * Math.cos((lat1r + lat2r) / 2); final double y = lat2r - lat1r; return R * Math.sqrt(x * x + y * y); }  static double distance(double lat1, double lon1, double lat2, double lon2); static double fastDistance(double lat1, double lon1, double lat2, double lon2); static double bearing(double lat1, double lon1, double lat2, double lon2); @NonNull static LatLng moveDirection(double latitude, double longitude, double bearing, double distance);  }
@Test public void fastDistance() { assertEquals(distance, Geo.fastDistance(seattle.latitude, seattle.longitude, la.latitude, la.longitude), 0.001 * distance); }