如何从球面上的当前点(纬度/经度)找到线段上最近的点

Posted

技术标签:

【中文标题】如何从球面上的当前点(纬度/经度)找到线段上最近的点【英文标题】:How to find closest point on line segment from current point on sphere surface (lat/lon) 【发布时间】:2019-09-01 02:41:52 【问题描述】:

例如: 比方说,我们在地球地图上有某种直墙,我们知道它的起点和终点的纬度/经度坐标:

wall.start.lat, wall.start.lon
wall.end.lat, wall.end.lon

我们还有一些对象:

object.lat
object.lon

如果我要从那个物体走到表面上的墙壁,我需要找到距离这个物体最近的墙壁点。

在飞机上很容易解决,但我一直坚持使用球体。

【问题讨论】:

球体中两点之间的距离,沿球体表面的弧线测量,称为“大圆距离。见Wikipedia。从垂直点到一个点的距离。弧见my answer @Ripi2 谢谢。它可能会有所帮助,但最后我试图获取最近点的坐标,而不是距离 对于最近的点,对两个墙端使用大圆方法并选择较小的距离。 【参考方案1】:

您可以在this latlong page使用越野距离部分

 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 δ13 = d13 / R;
var dAt = Math.acos(Math.cos(δ13)/Math.cos(dXt/R)) * R;

并应用目标点给定距离和距起点的方位方法来获取点坐标

【讨论】:

【参考方案2】:

我愿意:

    假设一个单位球体,计算从中心到线段端点的向量 叉积以获得包含线段的平面的法线 用对象点标准化长度和点积,以获得它与平面的距离 asin() 将其转换为沿曲面到线段大圆路径的距离 乘以实际半径得到合适的单位

您还需要对象点和线段端点之间的距离,以防它们变得更近。

【讨论】:

以上是关于如何从球面上的当前点(纬度/经度)找到线段上最近的点的主要内容,如果未能解决你的问题,请参考以下文章

给定一个纬度/经度,从 c# 中的经度/经度列表中找到最近的经度/经度对

如何使用 Google API 查找航点上的纬度和经度

如何找到给定纬度/经度以北 x 公里的纬度/经度?

获取给定当前点、距离和方位的纬度/经度

GIS中怎么将投影坐标转换成地理坐标

经纬度表示方法 经纬度表示方法以及其定义