Asked by:
Findind distance between two POINTS help

So i was trying to duplicate the distance formula on this page in C#
http://itouchmap.com/latlong.html
This is for distance between two locations.
This is my code
int R = 6371; double Lat1 = ((Double.Parse(SLat))*(Math.PI/180)); double Lat2 = ((Double.Parse(SLat2)) * (Math.PI / 180)); double deltaOmega = (Double.Parse(SLat)  Double.Parse(SLat2)) * (Math.PI / 180); double deltaLambda = (Double.Parse(SLong)  Double.Parse(SLong2)) * (Math.PI / 180); double a = Math.Sin(deltaOmega / 2) * Math.Sin(deltaOmega / 2) + Math.Cos(Lat1) * Math.Cos(Lat2) * Math.Sin(deltaLambda / 2) * Math.Sin(deltaLambda/ 2); double c = 2* Math.Atan2(Math.Sqrt(a), Math.Sqrt(1a)); double dis = R * c;
but i keep getting a distance that is two decimal places off
Can anyone verify that my translation of the equation is correct?
 Edited by kalel111 Tuesday, October 21, 2014 4:25 AM
Tuesday, October 21, 2014 4:24 AM
Question
All replies

Could you post the direct link to the formula you are implementing? I have not been able to find it on the website you linked to.Tuesday, October 21, 2014 8:01 AM

Sorry, wrong link.
this is the correct one:
http://www.movabletype.co.uk/scripts/latlong.html
Wednesday, October 22, 2014 1:04 AM 
No one can verify this for me??? Come on guys. You just have to look at my code!Thursday, October 23, 2014 2:22 PM

So i was trying to duplicate the distance formula on this page in C#
http://www.movabletype.co.uk/scripts/latlong.html
This is for distance between two locations.
This is my code
int R = 6371; double Lat1 = ((Double.Parse(SLat))*(Math.PI/180)); double Lat2 = ((Double.Parse(SLat2)) * (Math.PI / 180)); double deltaOmega = (Double.Parse(SLat)  Double.Parse(SLat2)) * (Math.PI / 180); double deltaLambda = (Double.Parse(SLong)  Double.Parse(SLong2)) * (Math.PI / 180); double a = Math.Sin(deltaOmega / 2) * Math.Sin(deltaOmega / 2) + Math.Cos(Lat1) * Math.Cos(Lat2) * Math.Sin(deltaLambda / 2) * Math.Sin(deltaLambda/ 2); double c = 2* Math.Atan2(Math.Sqrt(a), Math.Sqrt(1a)); double dis = R * c;
but i keep getting a distance that is two decimal places off
Can anyone verify that my translation of the equation is correct?
 Merged by Rob Caplan [MSFT]Microsoft employee, Owner Thursday, October 23, 2014 7:25 PM duplicate
Thursday, October 23, 2014 2:23 PM