39 | | 1. Find bounding box for the two point arrays |
40 | | 2. Check if bounding boxes intersecting. If so, send to old function |
41 | | 3. Find center of bounding boxes and calculate deltax and deltay from the two points |
42 | | 4. 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 :-) |
43 | | 5. Now we have a list with all vertexes with this calculated “z”-values together with the ordering-value from the geometry-array. |
44 | | 6. We order this list by the calculated “z”-value |
45 | | 7. 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 |
46 | | 8. 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. |
| 40 | |
| 41 | 1. Find bounding box for the two point arrays |
| 42 | 2. Check if bounding boxes intersecting. If so, send to old function |
| 43 | 3. Find center of bounding boxes and calculate deltax and deltay from the two points |
| 44 | 4. 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 :-) |
| 45 | 5. Now we have a list with all vertexes with this calculated “z”-values together with the ordering-value from the geometry-array. |
| 46 | 6. We order this list by the calculated “z”-value |
| 47 | 7. 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 |
| 48 | 8. 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. |