Changes between Version 2 and Version 3 of NewDistCalcGeom2Geom


Ignore:
Timestamp:
Nov 8, 2009, 12:32:20 PM (14 years ago)
Author:
nicklas
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • NewDistCalcGeom2Geom

    v2 v3  
    2929[[Image(b5.png, border=1)]]
    3030
     31The gain from this process is that we don't have to iterate through all point. But as shown every point we actually investigate needs more calculations than todays functions because we have to search both forward and backward for each calculated point. Maybe, because of this it is wise to just use this method if the number of vertexes is more than 20 or something like that.
     32
     33'''How this is done'''
     34
     35This calculation is implanted instead of the array_array function when there is no intersection.
     36I don’t know if the letters used is international but to describe a function of a line I here use y=k*x + z
     37The steps are:
     38
     391. Find bounding box for the two point arrays
     402. Check if bounding boxes intersecting. If so, send to old function
     413. Find center of bounding boxes and calculate deltax and deltay from the two points
     424. Calculate the “z” value from y=kx+z for each vertex with k-value from the slope between the two bbox-center points. To eliminate problems with dividing with zero and other limitations when getting closer to dividing with zero we instead change the x-axes with the y-axes by “mirroring”  the coordinate system. In that way the “z”-value represents a lines crosspoint to the x-axes instead of the usual y-axes crossing. Hope it is understandable since I don’t know the terminology, but it works :-)
     435. Now we have a list with all vertexes with this calculated “z”-values together with the ordering-value from the geometry-array.
     446. We order this list by the calculated “z”-value
     457. Now we take the two points from our list that is most close to each other according to this “z”-value and calculate the distance between them. We translate the distance value so it will be comparable with our “z”-values
     468. Now, we start the iteration through the vertexes. We iterate in the z-value order, which means we compare points close to the other geometry according to our z-values before we compare the values more far away. We also stop the iteration at ones the next vertex is more far away from the other geometry than our smallest found distance so far. This will narrow the search for each new mindistance we find.
    3147
    3248
    3349
    3450
     51