<bdo id='d3mqS'></bdo><ul id='d3mqS'></ul>
    <legend id='d3mqS'><style id='d3mqS'><dir id='d3mqS'><q id='d3mqS'></q></dir></style></legend>

      <small id='d3mqS'></small><noframes id='d3mqS'>

      1. <i id='d3mqS'><tr id='d3mqS'><dt id='d3mqS'><q id='d3mqS'><span id='d3mqS'><b id='d3mqS'><form id='d3mqS'><ins id='d3mqS'></ins><ul id='d3mqS'></ul><sub id='d3mqS'></sub></form><legend id='d3mqS'></legend><bdo id='d3mqS'><pre id='d3mqS'><center id='d3mqS'></center></pre></bdo></b><th id='d3mqS'></th></span></q></dt></tr></i><div id='d3mqS'><tfoot id='d3mqS'></tfoot><dl id='d3mqS'><fieldset id='d3mqS'></fieldset></dl></div>
      2. <tfoot id='d3mqS'></tfoot>

      3. 检查点是否在圆圈内

        时间:2023-09-17

            1. <small id='sLw3r'></small><noframes id='sLw3r'>

                <tbody id='sLw3r'></tbody>

            2. <legend id='sLw3r'><style id='sLw3r'><dir id='sLw3r'><q id='sLw3r'></q></dir></style></legend>

              <i id='sLw3r'><tr id='sLw3r'><dt id='sLw3r'><q id='sLw3r'><span id='sLw3r'><b id='sLw3r'><form id='sLw3r'><ins id='sLw3r'></ins><ul id='sLw3r'></ul><sub id='sLw3r'></sub></form><legend id='sLw3r'></legend><bdo id='sLw3r'><pre id='sLw3r'><center id='sLw3r'></center></pre></bdo></b><th id='sLw3r'></th></span></q></dt></tr></i><div id='sLw3r'><tfoot id='sLw3r'></tfoot><dl id='sLw3r'><fieldset id='sLw3r'></fieldset></dl></div>
              • <bdo id='sLw3r'></bdo><ul id='sLw3r'></ul>

                • <tfoot id='sLw3r'></tfoot>
                • 本文介绍了检查点是否在圆圈内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一点用纬度/经度表示

                  I have a point expressed in lat/long

                  Position louvreMuseum = new Position( 48.861622, 2.337474 );
                  

                  我有一个以米表示的半径值.我需要检查另一个点(也以 lat/long 表示)是否在圆圈内.

                  and I have a radius value expressed in meters. I need to check if another point, also expressed in lat/long, is inside the circle.

                  如果我在平坦的表面上,我可以简单地使用公式

                  If I were on a flat surface I can simply use the formula

                  (x - center_x)^2 + (y - center_y)^2 <= radius^2
                  

                  正如这些 SO answer 中深入解释的那样.

                  as deeply explained in these SO answer.

                  但是根据纬度/经度的用法,由于行星的球形性质,我不能使用该公式.

                  However as per the latitude/longitude usage I can not use that formula because of the spherical nature of the planet.

                  如何计算任何给定点到中心的距离以与半径进行比较?

                  How can I calculate a distance from any given point to the center to be compared with the radius?

                  推荐答案

                  计算两个坐标之间距离的函数(从这里转换为C# 回答):

                  Function to calculate the distance between two coordinates (converted to C# from this answer):

                  double GetDistance(double lat1, double lon1, double lat2, double lon2) 
                  {
                      var R = 6371; // Radius of the earth in km
                      var dLat = ToRadians(lat2-lat1);
                      var dLon = ToRadians(lon2-lon1); 
                      var a = 
                          Math.Sin(dLat/2) * Math.Sin(dLat/2) +
                          Math.Cos(ToRadians(lat1)) * Math.Cos(ToRadians(lat2)) * 
                          Math.Sin(dLon/2) * Math.Sin(dLon/2);
                  
                      var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1-a)); 
                      var d = R * c; // Distance in km
                      return d;
                  }
                  
                  double ToRadians(double deg) 
                  {
                      return deg * (Math.PI/180);
                  }
                  

                  如果两点之间的距离小于半径,那么它在圆内.

                  If the distance between the two points is less than the radius, then it is within the circle.

                  这篇关于检查点是否在圆圈内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:获取公共 Internet IP 地址/地理位置的智能方法 下一篇:IP 地址为 127.0.0.1 的地理定位错误

                  相关文章

                    <legend id='wENHZ'><style id='wENHZ'><dir id='wENHZ'><q id='wENHZ'></q></dir></style></legend>

                      <bdo id='wENHZ'></bdo><ul id='wENHZ'></ul>

                    <small id='wENHZ'></small><noframes id='wENHZ'>

                      <tfoot id='wENHZ'></tfoot>
                      <i id='wENHZ'><tr id='wENHZ'><dt id='wENHZ'><q id='wENHZ'><span id='wENHZ'><b id='wENHZ'><form id='wENHZ'><ins id='wENHZ'></ins><ul id='wENHZ'></ul><sub id='wENHZ'></sub></form><legend id='wENHZ'></legend><bdo id='wENHZ'><pre id='wENHZ'><center id='wENHZ'></center></pre></bdo></b><th id='wENHZ'></th></span></q></dt></tr></i><div id='wENHZ'><tfoot id='wENHZ'></tfoot><dl id='wENHZ'><fieldset id='wENHZ'></fieldset></dl></div>