Hello,

recently I was asked for a formula to calculate the center of a circle based on GPS coords (Lon/Lat) of 3 registered points at the edge of the circle. The problem is quite complicated due to the spherical surface (it's not the same as the center of the planar circle!), however I found a brilliant solution at Ask Dr.Math (http://mathforum.org/library/drmath/view/68373.html).

I decided to calculate the example presented at Dr.Math in both excel and javascript and I get the same result:

Location 1: Lat 38.714642 Long -90.256857 Location 2: Lat 41.143586 Long -96.238873 Location 3: Lat 38.942661 Long -90.892235

Excel, JS -> center = Location 0: Lat 60.56656708626758 Long -69.01937823602283

however when I put some real-life GPS coords into the calculation I get different results in excel and JS.

P1: Lon 22,366813 Lat 51,159313

P2: Lon 22,387458 Lat 51,153109

P3: Lon 22,39142 Lat 51,167133

Excel -> center = P0: Lon 22,38085184 Lat -51,16107483

JS -> center = P0: Lon 22.38085184 Lat 51.16107483

I see that the latitude in excel (cell 'W10' in the attached file) is calculated with negative value (-), which is wrong (northern latitude is the right one), but why does it happen? When I put some other coords for testing I get only northern latitudes.

I'm sending an excel table and js files with Dr.Maths' coords and my ones. I use Polish version of excel (hope the formulas would change automaticly in other versions) and test my js script at https://js.do/

Anybody could help?

More Jakub Andrzej Kuna's questions See All
Similar questions and discussions