|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Calculate displacementHello, I am writing an application were I need to calculate the distance between two points. The two points are given in latitude and longitude coordinates (dd.mm.ss). How do you calculate this distance ? Is it neccessary in your application to take into account that the radius of earth is not constant ? Best regards HÃ¥vard Holm _______________________________________________ GPSdrive mailing list GPSdrive@... http://lists.gpsdrivers.org/mailman/listinfo/gpsdrive |
|
|
Re: Calculate displacementHaavard Holm wrote:
> I am writing an application were I need to calculate the > distance between two points. > The two points are given in latitude and longitude > coordinates (dd.mm.ss). > > How do you calculate this distance ? What you want is a formula to calculate Great-Circle distances, aka the Geodesic distance. There is a program called "geod" which comes with PROJ.4 (often in a linux package called "proj") which will do this for you, if you use geo applications on Linux it is probably already installed. https://trac.osgeo.org/proj/ > Is it neccessary in your application to take into account that the > radius of earth is not constant ? Yes. Probably the best program out there for this sort of thing is the more modern version of geod called "geodesic" (same author). You can find it at http://home.comcast.net/~gevenden56/geodesy/project/ The +ellps=<ellipse> command line option tells it which ellipsoid model of the Earth to use. More help can be found on the PROJ.4 mailing list. regards, Hamish _______________________________________________ GPSdrive mailing list GPSdrive@... http://lists.gpsdrivers.org/mailman/listinfo/gpsdrive |
|
|
Re: Calculate displacementHaavard Holm wrote:
> > > Hello, > > I am writing an application were I need to calculate the distance > between two points. > The two points are given in latitude and longitude coordinates (dd.mm.ss). > > How do you calculate this distance ? Is it neccessary in your > application to take into > account that the radius of earth is not constant ? To determine the rhumb course and distance between {Lat1,Long1} and {Lat2,Long2) determine X where X = (Lat2 - Lat1)/ 60 = difference in latitude in nautical miles = the adjacent side of the triangle then determine Y where Y = 60 (Long1 - Long2) cos( (Lat1+Lat2)/2) = Departure in nautical miles = the opposite side of the triangle then course to go is Y/X = atan( theta) (since tan = opposite over adjacent) and X = r cos(theta) and Y = r sin(theta) and distance r = X / cos( theta) or r = Y / sin (theta) Note, that if you are doing this from a map or chart, any degrees,minutes,seconds readings (dd.mm.ss) will have to be transformed to dd.ddddddd form before doing the trigonometric calculations. (Good scientific calculators, such as Hewlett-Packard and TI have these conversions built in....usually as HMS->HR or similar naming) Also note that you have to be careful with your naming scheme to get the correct quadrant for the atan coversion angle. And if you are writing a program in 'C' or 'C++', the math library (libm) only works with radians, not degrees, so you have to do: HMS -> HR ( add, subtract, etc) -> radians -> sin or cos etc. *and then back*! If you want to learn more (and there is LOTS more to learn) download a copy of 'The American Practical Navigator' commonly called 'Bowditch' after the original author (in 1802). You need to read Chapter 24 and section 2411 particularly. The Bi-Centennial Edition is available as a 37M zip file, expandable to a 42M pdf file from http://www.nga.mil/portal/site/maritime/?epi_menuItemID=c56aa099e2bff9525b2a7fbd3227a759&epi_menuID=35ad5b8aabcefa1a0fc133443927a759&epi_baseMenuID=e106a3b5e50edce1fec24fd73927a759 Yes, that is all one URL! There ARE java programs available through the web if you just want to wnat the course and range between a couple of spots. Of course, most GPS units make it effectively impossible to determine the bearing and range between arbitrary positions, although you CAN do it with some units if you can ping the places as waypoints. But if you are not there (yet) you cannot. Also, no standalone GPS can tell you where any arbitrary place is, in lat-long, given a range and bearing from 'here'.... Geoff -- Please let me know if anything I say offends you. I may wish to offend you again in the future. Tux says: "Be regular. Eat cron flakes." _______________________________________________ GPSdrive mailing list GPSdrive@... http://lists.gpsdrivers.org/mailman/listinfo/gpsdrive |
|
|
Re: Calculate displacementHaavard Holm wrote:
> > > Hello, > > I am writing an application were I need to calculate the distance > between two points. > The two points are given in latitude and longitude coordinates (dd.mm.ss). > > How do you calculate this distance ? Is it neccessary in your > application to take into > account that the radius of earth is not constant ? > Addendum. The curvature of the earth is taken care of in the formula I gave, in the (Lat1 + Lat2)/2 calculation. This is mid-latitude calculation. This is not "precise" compared to great circle calculations, but the error is less than about one-tenth of a mile, at ranges less than 600 miles, and latitudes below 60 degrees...and do you really care that it is 399.4025 miles between 2 places, as compared to '400' if you are flying, sailing, or driving? Great circle calculations involve a LOT more number crunching. Geoff > -- Please let me know if anything I say offends you. I may wish to offend you again in the future. Tux says: "Be regular. Eat cron flakes." _______________________________________________ GPSdrive mailing list GPSdrive@... http://lists.gpsdrivers.org/mailman/listinfo/gpsdrive |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |