道格拉斯-普克 - 球体表面上从点到圆的最短弧
我见过许多使用 Douglas-Peucker 折线简化算法的各种编程语言的示例来生成要在 Google 地图上使用的 GPolyline。 当用平面上的折线表示时,该算法涉及计算点和线(穿过其他两个点)之间的距离。
到目前为止,我看到的所有示例都以非常幼稚的方式应用该算法,只需将 x 和 y 替换为纬度和经度。只要折线非常局部化,不太靠近极点,并且不穿过 180° 子午线,这可能会产生可接受的结果,但我想实现该算法的更通用版本。
所以,如果我没记错的话,我需要计算球体表面上最短弧的长度,从一个点到穿过球体表面的另外两个点的圆,其中心与球体(地球)的中心。
有谁知道计算这个长度的公式吗?
提前致谢
I have seen many examples in various programming languages that are using the Douglas-Peucker polyline simplification algorithm to produce a GPolyline to be used on Google Maps.
The algorithm, when expressed for polylines on a plan, involves the calculation of the distance between a point and a line (passing through two other points).
Now all the examples I have seen so far are applying the algorithm in a very naïve way, simply by replace x and y by the latitude and longitude. This may produce acceptable results as long as the polyline is very localized, not too close to a pole, and does not cross the 180° meridian, but I would like to implement a more general version of the algorithm.
So, If I am not mistaken, I would need to compute the length of the shortest arc on the surface of a sphere, from a point to the circle passing through two other points of the surface of the sphere, the center of which coinciding with the center of the sphere (the earth).
Does anyone know the formula that computes this length?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将尝试用单位向量 p、q 和 r 来表达所有内容,它们可以被视为单位上的点以原点 0 为中心的球体 Σ。您可以通过按地球半径放大将其转换为陆地量。这里有一些背景材料。
我们想要找到从 p 到大圆 C 经过 q 和 的大圆距离 d >r。 C 是平面 P 与球体 Σ 的交线,其中 P 是穿过 P 的平面strong>q、r 和原点 0。 d 只是 p 和 P 之间的角度 θ(以弧度表示)。 P 的法向量是归一化叉积 q×r/sinφ,其中 φ 是 q 之间的角度> 和r。
我们最终得到
θ = arcsin(p⋅(q×r)/sinφ)
正如我所说,这里的所有内容都按比例放大地球半径R。所以这三个点是Rp、Rq、R r,距离为Rθ。
但是,如果您只想找到距离最短的点/线组合,则可以省略乘以R。事实上,您可以省略 arcsin() 并仅查看 p⋅(q×r)/sinφ 的相对大小。
I'll try to express everything in terms of unit vectors p, q, and r, which can be thought of as points on a unit sphere Σ centered at the origin 0. You can convert that to terrestrial quantities by scaling up by the radius of the earth. There is some background material here.
We want to find the great circle distance d from p to the great circle C going through q and r. C is the intersection of a plane P and the sphere Σ, where P is the plane that passes through q, r, and the origin 0. d is simply the angle θ (expressed in radians) between p and P. The normal vector for P is the normalized cross product q×r/sinφ, where φ is the angle between q and r.
We end up with
θ = arcsin(p⋅(q×r)/sinφ)
As I said, everything here gets scaled up by the radius R of the earth. So the three points are Rp, Rq, Rr, and the distance is Rθ.
However, if all you want is to find a point/line combo with the shortest distance, you can omit multiplying by R. In fact you can omit the arcsin() and just look at the relative sizes of the p⋅(q×r)/sinφ.