Tutorial :how to check radius of 10 meter from x,y position - from GPS



Question:

i have this position from GPS:

40.715192,-74.005795

how to check if i in the range of 10 meter radius ?

thank's in advance


Solution:1

Use Haversine formula http://en.wikipedia.org/wiki/Haversine_formula

Pseudocode:

R = 6371; // corrected earth radius, km  dLat = degToRad(lat2-lat1);  dLon = degToRad(lon2-lon1);   a = sin(dLat/2) * sin(dLat/2) +          cos(degToRad(lat1)) * cos(degToRad(lat2)) *           sin(dLon/2) * sin(dLon/2);   c = 2 * atan2(sqrt(a), sqrt(1-a));   distance = R * c;  

degToRad converts degress to radians, see e.g. here


Solution:2

I was looking for something similar and found this: http://megocode3.wordpress.com/2008/02/05/haversine-formula-in-c/


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »