How to calculate Cross-Track error (GPS/Core Location)

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

Tags:

Ios

Iphone

Xcode