xcode 如何计算跨轨道误差(GPS/核心位置)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3997410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to calculate Cross-Track error (GPS/Core Location)
提问by Brad
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.
对于那些不熟悉的人:您正在沿着一条从“A”点到“B”点的线行驶。在运输过程中,当您偏离那条线时,从您当前位置到该线的距离就是跨航迹误差。
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.
换句话说-如果您知道用于确定此问题的“大圆”公式,请告诉我-但这不是直角笛卡尔几何问题。
采纳答案by Brad
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
公式: 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 pointR
is the earth's radius
δ13
是从起点到第三点的(角度)距离θ13
是(初始)从起点到第三点的方位θ12
是(初始)从起点到终点的方位R
是地球的半径
JavaScript:
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.
在这里,大圆路径由起点和终点标识 - 根据您使用的初始数据,您可以使用上面的公式来获得相关的距离和方位。的符号dxt
告诉您第三个点在路径的哪一侧。
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
公式: dat = acos( cos(δ13) / cos(δxt) ) ? R
where:
在哪里:
δ13
is (angular) distance from start point to third pointδxt
is (angular) cross-track distanceR
is the earth's radius
δ13
是从起点到第三点的(角度)距离δxt
是(角)跨轨道距离R
是地球的半径
JavaScript:
JavaScript:
var dAt = Math.acos(Math.cos(δ13)/Math.cos(dXt/R)) * R;
回答by James Branigan
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
http://www.movable-type.co.uk/scripts/latlong-vincenty.html
The Vincenty algorithm is more accurate that the Haversine algorithm.
Vincenty 算法比Haversine 算法更准确。
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.
一旦获得了 AB、AC 和 BC 的准确距离,就可以直接确定从 C 到线 AB 的距离。类似于从 AB 上的点到 C 的距离的二分搜索,寻找最短的值。
James
詹姆士
回答by DexterW
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.
如果处理纬度和经度,您正在寻找的论坛是“Haversine”公式。它考虑了地球表面的曲率。
http://en.wikipedia.org/wiki/Haversine_formula
http://en.wikipedia.org/wiki/Haversine_formula
Good luck.
祝你好运。
回答by Kevin
The CLLocation API provides
CLLocation API 提供
- (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.
它使用了一个考虑地球曲率的公式(它没有指定是Haversine还是Vincenty或其他)。这将返回 2 个 CLLocations 之间的距离(以米为单位),但不考虑高度的任何差异。