tags:

views:

24

answers:

3

Does anyone know how to determine determine the "Cross-Track Error"?

For those who are unfamiliar: You are driving along a line from Point "A" to point "B". When in transit, when you veer off that line, the distance from your current position to the line is the cross-track error.

I have a simple algorithm now which works, using basic geometry with the latitude and longitude of the three points - the problem is that it does not take "great circle" calculations into account (i.e. actual meters-per-degree longitude varies depending on your latitude, and does not equal that of the latitude).

In other words - if you know of a "great circle" formula for determining this, please let me know - but it is not a straight Cartesian geometry problem.

A: 

If dealing with latitude and longitude, the forumla you're looking for is the "Haversine" formula. It takes into account the curvature of the earth's surface.

http://en.wikipedia.org/wiki/Haversine_formula

Good luck.

DexterW
Thanks for the tip - but its not just the distance from point to point that is the issue - but from your current location to the tangent point on the A-B line...
Brad
A: 

Brad,

I'm not sure which ellipsoid model you are using since you don't say. If you aren't using an ellipsoid model in you current calculations, you may find this helpful:

http://www.movable-type.co.uk/scripts/latlong-vincenty.html

The Vincenty algorithm is more accurate that the Haversine algorithm.

Once you have accurate distances for A-B, A-C and B-C, it should be straightforward to determine your distance from C to the line A-B. Something like a binary search of the distances from points on A-B to C, looking for the shortest value.

James

James Branigan
A: 

The CLLocation API provides

- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location

Which uses a formula (it does not specify whether is it Haversine or Vincenty or other) that takes into account the curvature of the earth. This returns the distance in meters between the 2 CLLocations but does not account for any difference in altitude.

Kevin
I knew this already - but your post has me re-thinking it. Though, the problem is that it's not as simple as determining the distance from one point to the next - but from your current location to the tangential intersection of the A-B line - and I still need to figure out what *that* point is.
Brad