public void addGreatCircle(final GeoPoint startPoint, final GeoPoint endPoint, final int numberOfPoints) {
		//	adapted from page http://compastic.blogspot.co.uk/2011/07/how-to-draw-great-circle-on-map-in.html
		//	which was adapted from page http://maps.forum.nu/gm_flight_path.html

		// convert to radians
		final double lat1 = startPoint.getLatitude() * Math.PI / 180;
		final double lon1 = startPoint.getLongitude() * Math.PI / 180;
		final double lat2 = endPoint.getLatitude() * Math.PI / 180;
		final double lon2 = endPoint.getLongitude() * Math.PI / 180;

		final double d = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((lat1 - lat2) / 2), 2) + Math.cos(lat1) * Math.cos(lat2)
				* Math.pow(Math.sin((lon1 - lon2) / 2), 2)));
		double bearing = Math.atan2(Math.sin(lon1 - lon2) * Math.cos(lat2),
				Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon1 - lon2))
				/ -(Math.PI / 180);
		bearing = bearing < 0 ? 360 + bearing : bearing;

		for (int i = 0, j = numberOfPoints + 1; i < j; i++) {
			final double f = 1.0 / numberOfPoints * i;
			final double A = Math.sin((1 - f) * d) / Math.sin(d);
			final double B = Math.sin(f * d) / Math.sin(d);
			final double x = A * Math.cos(lat1) * Math.cos(lon1) + B * Math.cos(lat2) * Math.cos(lon2);
			final double y = A * Math.cos(lat1) * Math.sin(lon1) + B * Math.cos(lat2) * Math.sin(lon2);
			final double z = A * Math.sin(lat1) + B * Math.sin(lat2);

			final double latN = Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
			final double lonN = Math.atan2(y, x);
			addPoint(latN / (Math.PI / 180), lonN / (Math.PI / 180));
		}
	}
public void addGreatCircle ( final GeoPoint startPoint , final GeoPoint endPoint , final int numberOfPoints ) { final double lat1 = startPoint . getLatitude ( ) * Math . PI / 180 ; final double lon1 = startPoint . getLongitude ( ) * Math . PI / 180 ; final double lat2 = endPoint . getLatitude ( ) * Math . PI / 180 ; final double lon2 = endPoint . getLongitude ( ) * Math . PI / 180 ; final double d = 2 * Math . asin ( Math . sqrt ( Math . pow ( Math . sin ( ( lat1 - lat2 ) / 2 ) , 2 ) + Math . cos ( lat1 ) * Math . cos ( lat2 ) * Math . pow ( Math . sin ( ( lon1 - lon2 ) / 2 ) , 2 ) ) ) ; double bearing = Math . atan2 ( Math . sin ( lon1 - lon2 ) * Math . cos ( lat2 ) , Math . cos ( lat1 ) * Math . sin ( lat2 ) - Math . sin ( lat1 ) * Math . cos ( lat2 ) * Math . cos ( lon1 - lon2 ) ) / - ( Math . PI / 180 ) ; bearing = bearing < 0 ? 360 + bearing : bearing ; for ( int i = 0 , j = numberOfPoints + 1 ; i < j ; i ++ ) { final double f = 1.0 / numberOfPoints * i ; final double A = Math . sin ( ( 1 - f ) * d ) / Math . sin ( d ) ; final double B = Math . sin ( f * d ) / Math . sin ( d ) ; final double x = A * Math . cos ( lat1 ) * Math . cos ( lon1 ) + B * Math . cos ( lat2 ) * Math . cos ( lon2 ) ; final double y = A * Math . cos ( lat1 ) * Math . sin ( lon1 ) + B * Math . cos ( lat2 ) * Math . sin ( lon2 ) ; final double z = A * Math . sin ( lat1 ) + B * Math . sin ( lat2 ) ; final double latN = Math . atan2 ( z , Math . sqrt ( Math . pow ( x , 2 ) + Math . pow ( y , 2 ) ) ) ; final double lonN = Math . atan2 ( y , x ) ; addPoint ( latN / ( Math . PI / 180 ) , lonN / ( Math . PI / 180 ) ) ; } }
Draw a great circle.
@param startPoint start point of the great circle
@param endPoint end point of the great circle
@param numberOfPoints number of points to calculate along the path