For a point in an irregular polygon, what is the most efficient way to select the edge closest to the point?

Given an irregular polygon and a point inside that polygon, how do you determine which edge in a polygon is closest to a point?

Example

I probably have to run this calculation for a large set of points in the polygon (for example, 50-200 points).

+5
source share
3 answers
  • Calculate the nearest point on the line tangent to each edge of the polygon.
  • Calculate the nearest point on each line segment (the edge of the polygon) to the point in question.
  • Calculate the distance from the nearest point on each line segment to the point in question.
  • . .

- (O (n)).

:

, .

  • p1 = {x1, y1}.
  • p2 = {x2, y2}.
  • p3 = {x3,y3}.
  • u - p1 p2, , p1 p2, p1+u(p2-p1)= p3 ( p3 , p1 p2).
  • u = ((x3 - x1)(x2 - x1)+(y3 - y1)(y2 - y1)) / ((x2 - x1)^2 + (y2 - y1)^2)
  • , p3 , p1 p2, pu = {xu, yu}
  • xu = x1 + u (x2 - x1)
  • yu = y1 + u (y2- y1)
  • , , pu = {xu, yu}
  • (.. p1s p2s)

( ) .

pu , 0 <= u <= 1. . , pu, p1, p2, and u, , :

  • Let pc = {xc, yc} .
  • IF u<0 THEN pc = p1
  • ELSE IF u>1 THEN pc = p2
  • ELSE pc = pu

.

  • p3 pc= `sqrt ((x3 - xc) ^ 2 + (y3 - yc) ^ 2)

. .

  • , . .

, , :

enter image description here

....

+18

: , ? , . ? ? , ?

, , , , , , . [] ( ), .

, - ( ), . (). ( ), , . , .

, (-), . , , .

P.S. , , . . , .

+1

All Articles