javascript - Translating math equation into JS -


im trying see if

 math.sqrt(            math.pow((position.coords.latitude -45),2) +             math.pow((position.coords.longitude-75),2)           )*79;  

matches this:

 distance store (km) = square root (                                        (current latitude – 45)^2 +                                         (current longitude ‐75)^2                                       ) *79 

right im getting 11,xxx km way much, don't see mistakes.

i tried doing this:

var x = math.pow((position.coords.latitude-45),2);     var y = math.pow((position.coords.longitude-75),2);     var z = math.sqrt(x+y);     var zz = z*79; 

but gave me same answer.

this formula valid short distances point of latitude 45 , longitude 75.

what want, you're not located in kazakstan, distance (45, -75),

math.sqrt(math.pow((lat-45),2)+math.pow((lon+75),2))*79;                                              ^ 

note it's precise coordinates precise , bigger distances should grab a better formula.


Comments