I have coded the simple Haversine formula (matlab) and it works fine (see below). If I provide 2 sets of latitude/longitude I can find the distance between them.
Despite this, I need to invert the procedure and calculate 2 sets of coordinates based on a specified distance. Although the formula is quite short, it seems difficult to back calculate.
For example, if I have the global coordinate (3,50), I want to calculate the corner coordinates of a square bounding box around this point with specified length/width.
lat1 = 3.5; lon1 = 50.1; lat2 = 3.6; lon2 = 50.1 % Input coordinates
delta_lat = degtorad(lat2 - lat1); % difference in latitude
delta_lon = degtorad(lon2 - lon1); % difference in longitude
a = sin(delta_lat/2)^2 + cos(lat1) * cos(lat2) * sin(delta_lon/2)^2;
c = 2 * atan2(sqrt(a), sqrt(1-a));
km = 6371 * c % distance in km
Thanks