Changes between Version 1 and Version 2 of NewDistCalcGeom2Geom


Ignore:
Timestamp:
Nov 8, 2009, 9:14:14 AM (14 years ago)
Author:
nicklas
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • NewDistCalcGeom2Geom

    v1 v2  
    66Here is two polygons that we want to calculate the smallest distance between.
    77
    8 [[Image(b1.png, 300, border=1)]]
     8[[Image(b1.png, border=1)]]
    99
    1010We start by finding an appropriate line between the polygons. The best one is the line between the center of the bounding boxes.
    1111
    12 [[Image(b2.png, 300, border=1)]]
     12[[Image(b2.png, border=1)]]
    1313
    1414Now we want to find how every vertex is placed along this line. We illustrate this with two perpendicular lines describing p5 in polygon1 and p12 in polygon2.
    1515
    16 [[Image(b3.png, 300, border=1)]]
     16[[Image(b3.png, border=1)]]
    1717
    1818Where those lines cross the x-axis gives us a value of where the points is situated along the line. We store that value for each vertex and order the vertexes by this value. P5 in polygon1 has the highest value of polygon1 and p12 has the lowest of polygon2.
    1919The first distance we calculate is between those two points. Because we not will calculate the points in ring order we have to also check the edge before and after, so we are testing polygon1 p4, p5, p6  against p11, p12, p13. That calculation will give us a shortest distance between p6 in polygon 1 and p13 in polygon2.
    2020
    21 [[Image(b4.png, 300, border=1)]]
     21[[Image(b4.png, border=1)]]
    2222
    2323We now know that the distance we are searching is somewhere between the distance between the two parallel lines and the distance that we we have found between the points p6 and p13.
     
    2727The result is a distance calculated like described by this line from st_shortestline.
    2828
    29 [[Image(b5.png, 300, border=1)]]
     29[[Image(b5.png, border=1)]]
    3030
    3131