I've to write a method that has the following signature
public class Position {
double longitude;
double latitude;
}
boolean isInsideTheArea(Position center, double radius, Position point);
So if point
is inside the area
that has the center
as its center and radius
as its radius in miles, this should return true
, false
otherwise.
Use the Haversine formula to compute the distance between center
and point
. If that distance is greater than radius
, return false
; otherwise return true
.
Pseudocode:
def haversineDistance(a, b):
# snip...
return foo
def isInsideTheArea (center, radius, point):
return haversineDistance(center, point) <= radius
hope this helps there are also some implementation examples
http://en.wikipedia.org/wiki/Haversine_formula