go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If I understand your question, by 'coordinates' you mean
'Cartesian coordinates', perhaps in two or three
dimensions. The problem is that you have N points
and you want to find the points that are close enough
together to have some sort of interaction.
From your description, you are making (N**2-N)/2 comparisons to find the points that are 'close enough' to require further calculations. If I have properly interpreted your problem, then I have an algorithm suggestion. It turns out that there is a very clever algorithm that will reduce the number of comparisons required to a very small number, perhaps something like 3*N. The algorithm you need can be found by searching for the words 'Voronoi' and 'Delaunay Triangulation.' These algorithms are most often described on two dimensional data, but I have heard rumors of success with this approach in up to six dimensions. Certainly three dimensional implementations are possible. I do not know of any perl implementations of these algorithms. Perhaps someone else knows of one. The field of study is called 'Computational Geometry.' I would try to describe the algorithms here, but geometry without pictures isn't much fun!
It should work perfectly the first time! - toma
In reply to Re: Iteration speed
by toma
|
|