I use Google Maps API v3 in my java project. I need to find the Euclidean distance between two points. But when I use the ordinary formula for calculating the Euclidean distance the result is somehow wrong:
For example:
Let say I have two points New York (43.2994285, -74.2179326) and Stockholm (59.3293235, 18.0685808) and I want to calculate the Euclidean distance for these two points:
double distance = Math.sqrt(Math.pow(43.2994285 - 59.3293235, 2) + Math.pow(-74.2179326 - 18.0685808, 2)); distance = 93.66834091217483
the result is obvious wrong.
Then I realised that the beginning coordinate is not (0,0) as in Cartesian coordinate system. Actually the beggiinning is 51° 28' 38" N, 0° 00' 00" W (WGS 84). The referent point is Greenwich (51.4825766, -0.0076589).
So the procedure for calculating new coordinates is like this:
New York (|51.4825766 - 43.2994285|, |-0.0076589- (-74.2179326)|) = New York (8.1831481, 74.2102737)
Stockholm (|51.4825766 - 59.3293235|, |-0.0076589 - 18.0685808|) = Stockholm (7.8467469, 18.0762397)
And then apply the formula for Euclidean distance. My question is this a correct approach and is there any other way for doing this?