algorithmic modeling for Rhino
could I find and identified duplicate point3d in a list ( example) with a dictionary and a hashtable?
... or, had better to use some other particular criteria like point. distanceTo(), with a tolerance?
//moving the point3d searcher
// this is a simply function to get the closest point of the puntosSensibles List
int index ;
Point3d pCercano = ClosestPoint(searcher, puntosSensibles, out index);
//building a Line
Line pelo = new Line (searcher, puntosSensibles[index]);
// then I want to refuse any point fron puntosSensibles wich allready is an endline
// so this is what I tried
Hashtable pelos = new Hashtable();
if ( !pelos.ContainsKey(index))
// here I try to recover the lines
// some lexical mistake is here, Im afraid...( first time i use this )
foreach (DictionaryEntry <int,Point3d> nuevosPelos in pelos)
PELOS = cajaPelos;
a dictionary or hashtable will only allow you to find exact duplicates. If you want to have some tolerance control then you'll have to use distances. However you can speed up this search using a spatial tree.
is a procedure question:
the best way to find just once a point in a cloud points is
a.-- find a point in a list and verify if it is duplicate or not with a distance + tolerance
b.-- using a hashtable ( very powerfull tool, but I dont know how it operates with points lines... and objects lkje this)
If you're only looking for a single point then the best way is just to compare all the points. Building hash tables, spatial trees or dictionaries is only worthwhile if you have to search for a lot of points.
If you want to use a Hashtable then you can use the default hashing algorithm that is already available for Point3d. But it will only find collisions between points that are exactly the same. If they're a tenth of a nanometer apart then they will get different hashes and you will not find them.
The best way to search point-clouds is to build a spatial tree. k-D trees are popular, I like oc-trees myself. It takes some time to set up, but once you have a proper binary search tree then it becomes very quick to find nearest neighbours or to find all the points within a certain distance of a search locus, etc. etc.
What is the exact problem you're trying to solve?
the problem is to move a point ( "searcher" in the code above) within a points cloud, and draw a line to the closest point, but do not draw a line to the same point twice.
And just iterating over the points isn't fast enough?
You could try a sort optimization. It's not as fast as a search tree but it's easy to set up and it's easy to remove points from it without having to recalculate anything. I wrote a series of blog posts on point-finding, you may find it helpful:
how many of you are working together?
do you have hash code?
Im sure you're a lot.
He is Legion.
No, no, he is too good and he likes cats. He must be Bob: http://goo.gl/HbhfvX