开发者

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

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

For those who are unf开发者_如何学Goamiliar: 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.


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


This is this text from the link to the accepted answer - should it go dead:

Here’s a new one: I’ve sometimes been asked about distance of a point from a great-circle path (sometimes called cross track error).

Formula: dxt = asin( sin(δ13) ⋅ sin(θ13−θ12) ) ⋅ R

where:

  • δ13 is (angular) distance from start point to third point

  • θ13 is (initial) bearing from start point to third point

  • θ12 is (initial) bearing from start point to end point

  • R is the earth’s radius

JavaScript:

var δ13 = d13 / R;
var dXt = Math.asin(Math.sin(δ13)*Math.sin(θ13-θ12)) * R;

Here, the great-circle path is identified by a start point and an end point – depending on what initial data you’re working from, you can use the formulas above to obtain the relevant distance and bearings. The sign of dxt tells you which side of the path the third point is on.

The along-track distance, from the start point to the closest point on the path to the third point, is:

Formula: dat = acos( cos(δ13) / cos(δxt) ) ⋅ R

where:

  • δ13 is (angular) distance from start point to third point
  • δxt is (angular) cross-track distance
  • R is the earth’s radius

JavaScript:

var dAt = Math.acos(Math.cos(δ13)/Math.cos(dXt/R)) * R; 


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜