The approximate formulas are good enough for me. When I get back home I will try to get this working in J
I am no expert in radians/degrees and those kind of stuff so if someone more familiar with it can translate this to J I would be very happy. 2009/3/29, Tom Arneson <[email protected]>: > > The formulas are for a sphere and give approximate answers. If you want > more precise distances the surface should be the ellipsoid of revolution. > See: http://en.wikipedia.org/wiki/Geodesy and other references from that > site. > > Tom Arneson > Professional Land Surveyor > > -----Original Message----- > From: [email protected] [mailto: > [email protected]] On Behalf Of Björn Helgason > Sent: Sunday, March 29, 2009 08:37 > To: Programming forum > Subject: Re: [Jprogramming] Finding GPS coordinates with J > > I think I got the formula here so it is a question of translating it to J > and then to get the ring is to do the calculation for i.360 degrees and x > distance > > --------------------------------- > Formula: α = d/R (angular distance) > lat2 = lat1 + α.cos(θ) > Δφ = ln(tan(lat2/2+π/4)/tan(lat1/2+π/4)) > if E:W line q = cos(lat1) > otherwise q = Δlat/Δφ > Δlon = α.sin(θ)/q > lon2 = (lon1+Δlon+π) % 2.π − π > where ln is natural log and % is modulo, Δlon is taking shortest route > (<180°), and R is the earth’s radius > JavaScript: > lat2 = lat1 + d*Math.cos(brng); > var dPhi = Math.log(Math.tan(lat2/2+Math.PI/4)/Math.tan(lat1/2+Math.PI/4)); > var q = (Math.abs(lat2-lat1) > 1e-10) ? (lat2-lat1)/dPhi : Math.cos(lat1); > var dLon = d*Math.sin(brng)/q; > // check for some daft bugger going past the pole, normalise latitude if so > if (Math.abs(lat2) > Math.PI/2) lat2 = lat2>0 ? Math.PI-lat2 : > -(Math.PI-lat2); > lon2 = (lon1+dLon+Math.PI)%(2*Math.PI) - Math.PI; > > -------------------- > Formula: lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ)) > lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), > cos(d/R)−sin(lat1)*sin(lat2)) > d/R is the angular distance (in radians), where d is the distance > travelled and R is the earth’s radius > JavaScript: > var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) + > Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) ); > var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1), > Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2)); > Excel: lat2: =ASIN(SIN(lat1)*COS(d/ER) + COS(lat1)*SIN(d/ER)*COS(brng)) > lon2: =lon1 + ATAN2(COS(d/ER)-SIN(lat1)*SIN(lat2), > SIN(brng)*SIN(d/ER)*COS(lat1)) > --------------------------- > Trig functions take arguments in radians, so latitude, longitude, and > bearings in degrees > (either decimal or degrees/minutes/seconds) need to be converted to > radians, rad = π.deg/180. > When converting radians back to degrees (deg = 180.rad/π), West is negative > if using signed > decimal degrees. For bearings, values in the range -π to +π [-180° to > +180°] > need to be converted > to 0 to +2π [0°–360°]; this can be done by (brng+2.π)%2.π [brng+360)%360] > where % is the modulo > operator. > > 2009/3/29 Björn Helgason <[email protected]> > > > Thx > > I took a quick look at the links and it looks like there are good > formulas > > available. > > I hope to get some time soon to translate them into J as I want. > > > > 2009/3/28 Brian Schott <[email protected]> > > > > Bjorn, > >> > >> This search provides some good leads, I believe. > >> > >> > >> > http://www.google.com/search?hl=en&client=safari&rls=en&q=distance%2Cbearing+sphere&btnG=Search > >> > >> > >> > >> -- > >> (B=) <-----my sig > >> Brian Schott > >> ---------------------------------------------------------------------- > >> For information about J forums see http://www.jsoftware.com/forums.htm > >> > > > > > > > > -- > > Björn Helgason, Verkfræðingur > > Fugl&Fiskur ehf, > > Þerneyjarsundi 23, Hraunborgum > > Po Box 127,801 Selfoss , > > t-póst: [email protected] > > gsm: +3546985532 > > Landslags og skrúðgarðagerð, gröfuþjónusta > > http://groups.google.com/group/J-Programming > > > > > > Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans > > > > góður kennari getur stigið á tær án þess að glansinn fari af skónum > > /|_ .-----------------------------------. > > ,' .\ / | Með léttri lund verður | > > ,--' _,' | Dagurinn í dag | > > / / | Enn betri en gærdagurinn | > > ( -. | `-----------------------------------' > > | ) | (\_ _/) > > (`-. '--.) (='.'=) ♖♘♗♕♔♙ > > `. )----' (")_(") ☃☠ > > > > > > -- > Björn Helgason, Verkfræðingur > Fugl&Fiskur ehf, > Þerneyjarsundi 23, Hraunborgum > Po Box 127,801 Selfoss , > t-póst: [email protected] > gsm: +3546985532 > Landslags og skrúðgarðagerð, gröfuþjónusta > http://groups.google.com/group/J-Programming > > > Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans > > góður kennari getur stigið á tær án þess að glansinn fari af skónum > /|_ .-----------------------------------. > ,' .\ / | Með léttri lund verður | > ,--' _,' | Dagurinn í dag | > / / | Enn betri en gærdagurinn | > ( -. | `-----------------------------------' > | ) | (\_ _/) > (`-. '--.) (='.'=) ♖♘♗♕♔♙ > `. )----' (")_(") ☃☠ > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm -- Björn Helgason, Verkfræðingur Fugl&Fiskur ehf, Þerneyjarsundi 23, Hraunborgum Po Box 127,801 Selfoss , t-póst: [email protected] gsm: +3546985532 Landslags og skrúðgarðagerð, gröfuþjónusta http://groups.google.com/group/J-Programming Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans góður kennari getur stigið á tær án þess að glansinn fari af skónum /|_ .-----------------------------------. ,' .\ / | Með léttri lund verður | ,--' _,' | Dagurinn í dag | / / | Enn betri en gærdagurinn | ( -. | `-----------------------------------' | ) | (\_ _/) (`-. '--.) (='.'=) ♖♘♗♕♔♙ `. )----' (")_(") ☃☠ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
