<p dir="ltr"><br>
On 13 Jun 2015 5:06 pm, "Robert C. Helling" <<a href="mailto:helling@atdotde.de">helling@atdotde.de</a>> wrote:<br>
><br>
><br>
> On 13 Jun 2015, at 08:53, Linus Torvalds <<a href="mailto:torvalds@linux-foundation.org">torvalds@linux-foundation.org</a>> wrote:<br>
><br>
> > On Fri, Jun 12, 2015 at 2:34 PM, Anton Lundin <<a href="mailto:glance@acc.umu.se">glance@acc.umu.se</a>> wrote:<br>
> >><br>
> >> Sorry, One _degree_ in latitude is about 111.5 km where i live, and<br>
> >> thats the basis for the convertion that 10 udeg is about a meter.<br>
> >><br>
> >>> +     return sqrt(lat1.udeg*lat2.udeg + lon1.udeg*lon2.udeg) / 10;<br>
> ><br>
> > Ugh. I think that's a bit *too* simplified.<br>
> ><br>
> > You do want to have that multiplication with "cos(latitude)" because<br>
> > longitude lines are much further apart around the equator than in<br>
> > temperate areas..<br>
> ><br>
> > And don't you want to square the *differences* (with that latitude<br>
> > correction) rather than just multiply the lat/long pairwise together?<br>
> > That just looks insane.The distance from 0,0 to any other point is<br>
> > always zero? That's an interesting distance function.<br>
> ><br>
> > I guess there are few divesites where we need to worry about<br>
> > wraparound (much less 20 m apart), so those kinds of simplifications I<br>
> > can see, but you seem to have gone a bit overboard.<br>
> ><br>
><br>
> A somewhat simplified formula that saves a bit of trigonometry but deals correctly with wrap around and the fact that meridians have a distance proportional to cos(latitude) would be<br>
><br>
> sin(lon1-lon2)^2 * cos(lat1)^2 + sin(lat1-lat2)^2 < distance^2 / radius_of_earth^2</p>
<p dir="ltr">You could even save more trig and take advantage of the fact that sin(a) = ~a, for small a (in radians).</p>
<p dir="ltr">((lon1-lon2)×pi/180)^2 * cos(lat1)^2 + ((lat1-lat2)×pi/180)^2 < distance^2 / radius_of_earth^2</p>
<p dir="ltr">I'm not a programmer but I assume multiplying by pi/180 = 0.0175 is less expensive than sine</p>
<p dir="ltr">><br>
> This should be fine for distances much smaller than the radius of the earth. The right hand side is a constant known at compile time, so it should be figured out by the compiler already.<br>
><br>
> Best<br>
> Robert<br>
><br>
> --<br>
> .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO<br>
> Robert C. Helling     Elite Master Course Theoretical and Mathematical Physics<br>
>                       Scientific Coordinator<br>
>                       Ludwig Maximilians Universitaet Muenchen, Dept. Physik<br>
> print "Just another   Phone: +49 89 2180-4523  Theresienstr. 39, rm. B339<br>
>     stupid .sig\n";   <a href="http://www.atdotde.de">http://www.atdotde.de</a><br>
><br>
><br>
> _______________________________________________<br>
> subsurface mailing list<br>
> <a href="mailto:subsurface@subsurface-divelog.org">subsurface@subsurface-divelog.org</a><br>
> <a href="http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface">http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface</a><br>
><br>
</p>