algorithmic modeling for Rhino
Hi everybody!
I'm trying to write a vb component that, given a bunch of points, and an integer, finds, in the the bunch, the two closest points to each other and deletes one of them. Then iterates the operation until the number of points in the bunch is equal to the integer.
Given pts my initial bunch of points, I have this problem:
Dim points As New Rhino.Collections.Point3dList(pts)
Dim p As Point3d = pts(i)
n = points.ClosestIndex(p)
I get i=n since, of course, the closest point to p is p itself!
I initially thought to remove p from points, just before the ClosestIndex line, but, in that way all the indices of the following points will change...
so i thought to temporarily substitute p in points with a very far away point...
Can you came out with any better solution?
Thankyou!
Tags:
I'd write the code from scratch, it's not that difficult to loop over the collection. It is however extremely time consuming to loop over the collection twice to find the closest pair, then delete one of them (which one? move the remaining point so it's halfway between where it used to be and the new location?).
If performance becomes an issue, there are optimizations, but they will require a significant amount of additional code.
I'll post a from-scratch example in a bit.
--
David Rutten
david@mcneel.com
Seattle, WA
Implementation.
--
David Rutten
david@mcneel.com
Seattle, WA
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by