How to find duplicate 3d points?

Gary Herron gherron at islandtraining.com
Wed Jun 11 11:54:19 EDT 2008


oprah.chopra at gmail.com wrote:
> I have a large data file of upto 1 million x,y,z coordinates of
> points. I want to identify which points are within 0.01 mm from each
> other. I can compare the distance from each point to every other
> point , but this takes 1 million * 1 million operations, or forever!
>
> Any quick way to do it, perhaps by inserting just the integer portion
> of the coordinates into an array, and checking if the integer has
> already been defined before inserting a new point?
> --
> http://mail.python.org/mailman/listinfo/python-list
>   

There is a whole field of Math/CS research on problems like this called 
Computational Geometry.  It provides many algorithms for many geometric 
problems, including things like this.  

In particular, to categorize a list of points and find the 
NearestNeighbor, I'd suggest a KD-tree.  I believe this would turn your 
problem from O(N^2) to O(N log n) or so.

Happy google-ing and good luck.

Gary Herron




More information about the Python-list mailing list