Changes between Version 1 and Version 2 of NewDistCalcGeom2Geom
- Timestamp:
- 11/08/09 09:14:14 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TabularUnified NewDistCalcGeom2Geom
v1 v2 6 6 Here is two polygons that we want to calculate the smallest distance between. 7 7 8 [[Image(b1.png, 300,border=1)]]8 [[Image(b1.png, border=1)]] 9 9 10 10 We start by finding an appropriate line between the polygons. The best one is the line between the center of the bounding boxes. 11 11 12 [[Image(b2.png, 300,border=1)]]12 [[Image(b2.png, border=1)]] 13 13 14 14 Now 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. 15 15 16 [[Image(b3.png, 300,border=1)]]16 [[Image(b3.png, border=1)]] 17 17 18 18 Where 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. 19 19 The 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. 20 20 21 [[Image(b4.png, 300,border=1)]]21 [[Image(b4.png, border=1)]] 22 22 23 23 We 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. … … 27 27 The result is a distance calculated like described by this line from st_shortestline. 28 28 29 [[Image(b5.png, 300,border=1)]]29 [[Image(b5.png, border=1)]] 30 30 31 31