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

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

        圆上最接近线段python的点

        时间:2023-09-12
        <tfoot id='7e8xp'></tfoot>
        <i id='7e8xp'><tr id='7e8xp'><dt id='7e8xp'><q id='7e8xp'><span id='7e8xp'><b id='7e8xp'><form id='7e8xp'><ins id='7e8xp'></ins><ul id='7e8xp'></ul><sub id='7e8xp'></sub></form><legend id='7e8xp'></legend><bdo id='7e8xp'><pre id='7e8xp'><center id='7e8xp'></center></pre></bdo></b><th id='7e8xp'></th></span></q></dt></tr></i><div id='7e8xp'><tfoot id='7e8xp'></tfoot><dl id='7e8xp'><fieldset id='7e8xp'></fieldset></dl></div>
      1. <legend id='7e8xp'><style id='7e8xp'><dir id='7e8xp'><q id='7e8xp'></q></dir></style></legend>
      2. <small id='7e8xp'></small><noframes id='7e8xp'>

          <tbody id='7e8xp'></tbody>
          • <bdo id='7e8xp'></bdo><ul id='7e8xp'></ul>

                  本文介绍了圆上最接近线段python的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要找到一个盒子和一个圆之间的最近距离,但是,我意识到这可以分解为一条线段和一个圆之间的最近距离.

                  I need to find the closest distance between a box and a circle, however, I realize this can be broken up into the closest distance between a line segment and a circle.

                  • 我有两点point1_xpoint1_ypoint2_xpoint2_y<的线段/代码>
                  • 我有一个 circle,中心为 circle_xcircle_yradius radius
                  • I have a line segment of two points point1_x,point1_y and point2_x, point2_y
                  • I have a circle with center circle_x, circle_y and radius radius

                  是否有一个可以开箱即用的 python 库,如果没有,有人可以提供一个函数来支持它吗?

                  Is there a python library that will support this out of the box and if not can somebody present a function to do so?

                  (我相信我必须在圆上找到与直线相同斜率的切点?)

                  (I belive I have to locate the tangent point on the circle with the same slope as the line?)

                  推荐答案

                  有一种方法可以找到圆到矩形的最近距离(此处为轴方向).
                  矩形边将平面分成 9 块.我们可以找到包含圆心的部分(中心、左上、左等),并计算所需的距离.矩形ABCD和圆心E:

                  There exists a method to find the closest distance from circle to rectangle (axis-oriented here).
                  Rectangle sides divide plane into 9 pieces. We can find what piece (central, left-top, left etc) contains circle center, and calculate needed distance. Rectangle ABCD and circle center E:

                  德尔福代码:

                  //returns closest distance from circle to rectangle
                  //0 if intersection or inclusion occurs
                  function CircleRectDistance(CX, CY, CR: Integer; RR: TRect): Double;
                  var
                    wh, hh, dx, dy, t, SquaredDist: Double;
                  begin
                    SquaredDist := 0;
                  
                    //halfwidth and halfheight
                    wh := 0.5 * (RR.Right - RR.Left);
                    hh := 0.5 * (RR.Bottom - RR.Top);
                  
                    //distances to rectangle center
                    dx := CX - 0.5 * (RR.Left + RR.Right);
                    dy := CY - 0.5 * (RR.Top + RR.Bottom);
                  
                    //rectangle sides divide plane to 9 parts,
                    t := dx + wh;
                    if t < 0 then
                      SquaredDist := t * t
                    else begin
                      t := dx - wh;
                      if t > 0 then
                        SquaredDist := t * t
                    end;
                    t := dy + hh;
                    if t < 0 then
                      SquaredDist := SquaredDist + t * t
                    else begin
                      t := dy - hh;
                      if t > 0 then
                        SquaredDist := SquaredDist + t * t
                    end;
                  
                    if SquaredDist < CR * CR  then
                      Result := 0
                    else
                      Result := Sqrt(SquaredDist)- CR;
                  end;
                  

                  这篇关于圆上最接近线段python的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <tbody id='NDbTe'></tbody>

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

                  • <bdo id='NDbTe'></bdo><ul id='NDbTe'></ul>

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

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