最近的网格方形到球坐标中的一个点

时间:2009-09-23 01:58:10

标签: algorithm geometry computer-science gis

我正在编写一种算法,我将球体表面分解为网格点(为简单起见,我将网格线平行并垂直于子午线)。给定点A,我希望能够有效地获取任何网格“正方形”并确定具有最小球面坐标距离AB的正方形中的点B.在简并的情况下,“正方形”实际上是“三角形”。

我实际上只是使用它来限制我正在搜索哪个方块,所以如果它只有一点点关闭,我也可以接受下限。出于这个原因,我需要算法非常快,否则最好只是失去准确性并搜索更多的方块。

4 个答案:

答案 0 :(得分:4)

对于球体上的点,当沿球体表面测量时,最接近全3D空间的点也将最接近。实际距离会有所不同,但如果你只是在最近的点之后,最简单的方法是最小化3D距离,而不是担心大圆弧等。

要查找球体上两个(latitidude,经度)点之间的实际大圆距离,您可以使用this link中的第一个公式。

答案 1 :(得分:3)

为了清楚起见,有几点。

除非你特别希望这些方块是方形的(因此不能完全适合这种关于经络的平行和垂直布局),否则这些不是正方形。如果正方形的尺寸很大,这一点尤为明显。

这个问题涉及一个[完美]领域。如果我们考虑地球(或其他行星)的扁平极点,那么事情会有所不同。

以下是适合该法案的“算法”,我怀疑它是最优的,但可以提供良好的基础。 编辑:请参阅Tom10建议使用点之间的平坦3D距离而不是相应的大圆距离(即绳索而不是弧线),因为这将大大降低复杂性。公式。

Problem layout:  (A, B and Sq as defined in the OP's question)
 A  : a given point the the surface of the sphere
 Sq : a given "square" from the grid 
 B  : solution to problem : point located within Sq which has the shortest 
      distance to A.
 C  : point at the center of Sq

Tentative algorithm:
Using the formulas associated with [Great Circle][1], we can:
 - find the equation of the  circle that includes A and C
 - find the distance between A and C. See the [formula here][2] (kindly lifted
    from Tom10's reply).
 - find the intersect of the Great Circle arc between these points, with the
   arcs  of parallel or meridian defining the Sq.
   There should be only one such point, unless this finds a "corner" of Sq, 
   or -a rarer case- if the two points are on the same diameter (see 
   'antipodes' below).
Then comes the more algorithmic part of this procedure (so far formulas...):
 - find, by dichotomy, the point on Sq's arc/seqment which is the closest from
   point A.  We're at B! QED.

Optimization:  
 It is probably possible make a good "guess" as to the location
 of B, based on the relative position of A and C, hence cutting the number of
 iterations for the binary search.
 Also, if the distance A and C is past a certain threshold the intersection
 of the cicles' arcs is probably a good enough estimate of B.  Only when A
 and C are relatively close will B be found a bit further on the median or
 parallel arc in these cases, projection errors between A and C (or B) are
 smaller and it may be ok to work with orthogonal coordinates and their 
 simpler formulas.

Another approach is to calculate the distance between A and each of the 4 
corners of the square and to work the dichotomic search from two of these
points (not quite sure which; could be on the meridian or parallel...)

( * ) *Antipodes case*:  When points A and C happen to be diametrically 
opposite to one another, all great circle lines between A and C have the same
 length, that of 1/2 the circonference of the sphere, which is the maximum any
 two points on the surface of a sphere may be.  In this case, the point B will
 be the "square"'s corner that is the furthest from C. 

我希望这会有所帮助......

答案 2 :(得分:0)

懒惰的下界方法是找到到正方形中心的距离,然后减去半对角线距离并使用三角形不等式进行约束。鉴于这些不是真正的正方形,实际上会有两个对角线距离 - 我们将使用更大的距离。我想它也会相当准确。

答案 3 :(得分:0)