I am working on a python script that shatters a bunch of overlapping, gathers all the end points and builds node network for a Djikstra’s path mapping algorithm. The biggest problem I am having right now is how to determine if points are “equal”. Right now, when the overlapping lines get shattered, their overlapping ends might have slightly different endpoints. This difference is 10-11 decimal points to the right so is incredibly minute.
What is the best way to identify “same/similar” points?
One way is to subtract the coordinates, take the absolute value of the result and check if it’s less than your required tolerance. If so, the points can be considered to be “identical” within tolerance. You can use a short-circuit logic to make it go quicker.
In Python, you can also simply subtract the 3dpoint objects, it will return a vector, which you can check the magnitude of and see if it’s less than tolerance.
There is a Rhinoscriptsyntax method “PointCompare” but with very large numbers of points it might be slow. There is also a method CullDuplicatePoints if you have all the points in a list and only want unique points. Both methods allow a user-set tolerance as an argument.
I don’t know which is the fastest of all the above methods…