[PATCH] Simplify distance calculations

Linus Torvalds torvalds at linux-foundation.org
Fri Jun 12 23:53:11 PDT 2015


On Fri, Jun 12, 2015 at 2:34 PM, Anton Lundin <glance at acc.umu.se> wrote:
>
> Sorry, One _degree_ in latitude is about 111.5 km where i live, and
> thats the basis for the convertion that 10 udeg is about a meter.
>
>> +     return sqrt(lat1.udeg*lat2.udeg + lon1.udeg*lon2.udeg) / 10;

Ugh. I think that's a bit *too* simplified.

You do want to have that multiplication with "cos(latitude)" because
longitude lines are much further apart around the equator than in
temperate areas..

And don't you want to square the *differences* (with that latitude
correction) rather than just multiply the lat/long pairwise together?
That just looks insane.The distance from 0,0 to any other point is
always zero? That's an interesting distance function.

I guess there are few divesites where we need to worry about
wraparound (much less 20 m apart), so those kinds of simplifications I
can see, but you seem to have gone a bit overboard.

                Linus


More information about the subsurface mailing list