On 13 Jun 2015, at 08:53, Linus Torvalds <[email protected]> wrote:
> On Fri, Jun 12, 2015 at 2:34 PM, Anton Lundin <[email protected]> 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. > 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 sin(lon1-lon2)^2 * cos(lat1)^2 + sin(lat1-lat2)^2 < distance^2 / radius_of_earth^2 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. Best Robert -- .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO Robert C. Helling Elite Master Course Theoretical and Mathematical Physics Scientific Coordinator Ludwig Maximilians Universitaet Muenchen, Dept. Physik print "Just another Phone: +49 89 2180-4523 Theresienstr. 39, rm. B339 stupid .sig\n"; http://www.atdotde.de
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
