如何通过地图上的半径和中心计算东北坐标

How to calculate northEast coordinate by radius and center on map

我有这个公式:

var bounds = map.getBounds();

var center = bounds.getCenter();
var ne = bounds.getNorthEast();

// r = radius of the earth in statute miles
var r = 3963.0;  

// Convert lat or lng from decimal degrees into radians (divide by 57.2958)
var lat1 = center.lat() / 57.2958; 
var lon1 = center.lng() / 57.2958;
var lat2 = ne.lat() / 57.2958;
var lon2 = ne.lng() / 57.2958;

// distance = circle radius from center to Northeast corner of bounds
var dis = r * Math.acos(Math.sin(lat1) * Math.sin(lat2) + 
  Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1));

它通过NE和中心计算半径。 我需要:用js编写的地图上给定半径和中心计算NE坐标的公式

好的,首先我想这将有助于理解所用公式的来源。 甚至在此之前,请注意我将使用标准数学坐标。这与地理long/lat不同,但应该很容易转换

因此球体上的一点是 (x,y,z)= r*(cos p sin t, sin p sin t, cos t)。所以 p 是从 xy 的角度,tz 轴的角度。

如果你有两个点 (p,t) 和 (q, u),我们可以将第一个点旋转到 p=0,即在 x 轴上。这些点的坐标为 (0,t)(q-p,u)。现在我们围绕 y 旋转这些点,使第一个点成为北极。

[ cos t, 0, -sin t]   [x]     [ cos t, 0, -sin t]   [ cos(q-p) sin(u)]
[    0   1,   0   ] . [y]  =  [    0   1,   0   ] . [ sin(q-p) sin(u)] 
[ sin t, 0,  cos t]   [z]     [ sin t, 0,  cos t]   [       cos(u)    ]

z
z_new = sin(t) cos(q-p) sin(u) + cos(t)cos(u)

自然这里到北极的弧长就是

alpha = arcsin( sin(t) cos(q-p) sin(u) + cos(t)cos(u) )

对于真实距离,我们必须乘以球体的半径 r

现在反过来。我们有一个点 (p,t) 并且想要 (q,u) 鉴于它的方向是一个角度 beta 偏离北方和距离 d。在第一步中,我们将点 (p,t) 设置为北极。这使得第二点 (Pi + beta, d/r)(如果逆时针方向,注意角度在数学上是正的)。该系统必须旋转,使北极到达给定的 (p,t)。这是由

完成的
[  cos t, sin t,  0]   [ cos p, 0,  sin p]   [x]   
[ -sin p, cos t,  0] . [    0   1,   0   ] . [y]  
[   0   ,  0   ,  1]   [ -sin p, 0, cos p]   [z]   

设置(Pi + beta, d/r) = (gamma, theta)我们得到

z_new = -sin(p)cos(gamma)sin(theta)+cos(p)cos(theta)

因此:

u = arccos( z_new )

最后:

x_new = cos(t) ( cos(p)cos(gamma)sin(theta) + sin(p)cos(theta) ) + sin(theta)sin(gamma)sin(theta)

作为x_new = cos(q)sin(u)我们知道u

q = arccos( xnew / sin(u) ) = arccos( xnew / sqrt( 1 - z_new ) )

我希望我没问题,记住这是典型的数学极坐标,它必须转换为地理中的sin/cos用法和角度定义 .