Steve
Steve

Reputation: 175

Find nearest points on KML polygon

In the graphic:

How to find these nearest points mathematically?

Graphic

Upvotes: 0

Views: 112

Answers (1)

Alessandro Jacopson
Alessandro Jacopson

Reputation: 18623

result = an empty list of points

for each edge of the KML polygon:
    if the edge is completely inside the green circle:
        append to result the point on the edge that is closest to the green circle center (see https://math.stackexchange.com/questions/2193720/find-a-point-on-a-line-segment-which-is-the-closest-to-other-point-not-on-the-li) 
    else:
        if the edge has two different intersections with the green circle:
            find the two intersection P1 and P2
            append to result the point (P1+P2)/2
        else:
            if the edge has one intersection with the green circle:
                append to result the intersection
            endif
        endif
    endif
endfor

Upvotes: 1

Related Questions