【问题标题】:Find evenly distributed random points on a spherical cap在球冠上找到均匀分布的随机点
【发布时间】:2019-06-13 10:33:58
【问题描述】:

我的纬度、经度和半径为 400m-1000m,形成spherical cap。我需要在那个上限上找到一个随机点。这些点必须均匀分布在该区域上。

有一个关于查找random points in a circle 的相关问题。我的第一个想法是将帽子投影到笛卡尔平面上并使用圆算法。半径足够小,不会出现严重的错误。

我不确定投影然后将点转换回 lat/lng 是否是最简单的解决方案,或者对于这个问题还有什么其他可能的解决方案

【问题讨论】:

    标签: algorithm math geo


    【解决方案1】:

    您可以使用 sqrt-distribution 生成 0..360 范围内的随机方位角和随机距离以提供 unifrom 分布

    d = maxR * Sqrt(random(0..1))
    theta = random(0..1) * 2 * Pi
    

    然后按照here (Destination point given distance and bearing from start point) 的描述使用方位角和距离获取地理点坐标

    φ2 = asin( sin φ1 ⋅ cos δ + cos φ1 ⋅ sin δ ⋅ cos θ )
    λ2 = λ1 + atan2( sin θ ⋅ sin δ ⋅ cos φ1, cos δ − sin φ1 ⋅ sin φ2 )
    
    where   φ is latitude, λ is longitude, θ is the bearing
    (clockwise from north), δ is the angular distance d/R; 
    d being the distance travelled, R the earth’s radius
    

    【讨论】:

    • 这看起来不错。我只是想了解这一切。所以平方根中的随机更有可能选择更高的值来弥补空间更​​大的事实?
    • 是的。环形面积与平方半径成正比,所以为了提供均匀的填充,我们使用反函数Mathworld page
    • 得到这个工作,它运作良好。唯一让我印象深刻的是第二部分接受 lat,lng 的弧度。
    【解决方案2】:

    如 wiki 页面 theta + phi = 90 中所述,如果 phi 是纬度。另一方面,由于r 对于帽上的所有点都是固定的,我们只需要设置theta 的值。因此,您可以从0theta 值(与上限相关)中选择一个随机值,并通过解释的约束来定义该点。

    【讨论】:

      【解决方案3】:

      对于与球体半径相比非常小的圆盘,经纬度投影将简单地近似为椭圆,除非您非常靠近极点。

      首先计算给定纬度的拉伸:

      double k = cos(latitude * PI / 180);
      

      然后以纬度计算圆盘半径

      // A latitude arc-second is 30.87 meters
      double R = radius / 30.87 / 3600 * PI / 180;
      

      然后在圆中计算一个均匀的随机点

      double a = random() * 2 * PI;
      double r = R * sqrt(random());
      

      您在光盘中的随机点将是

      double random_lat = (latitude*PI/180 + r*cos(a))/PI*180;
      double random_longitude = (longitude*PI/180 + (r/k)*sin(a))/PI*180;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-07-21
        • 2020-04-04
        • 1970-01-01
        • 2021-07-20
        • 2012-03-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多