algorithmic modeling for Rhino
Hello,
I'm relatively new to grasshopper so bear with me here...
I have a cloud of points with a series of spheres, ten in all, each nested inside of each other. I'm trying to figure out how to sort those points into a series of lists based on which spheres they fall between, all without changing the position of the points. For instance:
I have 1306 points, and some number of them fall between the outer surface of sphere 8 and the inner surface of sphere 9, which is a larger sphere, with 8 nested inside. I need to move these points to their own list. In the end I'll have several lists of points, each within different zones of space.
Both the points and the spheres were generated in grasshopper.
Can ya'll offer any advice?
Tags:
Hi Zach,
you can do something like this,
First of all order your spheres by radius.
Take the smallest sphere and find its center point. Find all points from your point list which their distance from the center point is less (or equal) to the radius of the (smallest) sphere. Copy-Duplicate these points to a new list and then remove them from your point list. Here you have to add the list of points you found to another list (of lists (of points)).
Take the next (second smallest) sphere and apply the same algorithm for the remaining points in your point list.
Continue until your point list is empty (assuming that every point is inside the biggest sphere) , or until you apply your algorithm for all spheres (assuming that you have points outside the biggest sphere).
I hope this can help you somehow to solve your problem.
Thanks, that sounds like a good solution...but I'm not sure how to go about doing this? I'm able to create the test ranges of values between the spheres, but I'm not sure how to tell grasshopper to filter through the points on the list to determine which fit within the ranges.
I'd like to keep this as parametric as possible without breaking my data stream...meaning that if I modify the location of the input points the resulting ranges of points will update.
Lovely little problem. It certainly requires some really nifty tree-modification to get it done:
The logic is as follows:
It's very high level, even if it doesn't require many component.
This algorithm will work on any type of closed brep, as long as you supply them in the order of importance.
--
David Rutten
david@mcneel.com
Tirol, Austria
Hi Zach,
here's a script that would work with closed breps.
I now saw David's reply but I have already written the script so choose whatever fits best.
x is a list of Closed Breps/ Spheres
y is a list of points
and z is the index of the list of points between spheres.
Breps/Spheres are ordered by volume
private void RunScript(List<Brep> x, List<Point3d> y, int z, ref object A)
{
refPointList.Clear();
sortedSphereList.Clear();
fPoints.Clear();
refPointList.AddRange(y);
sortedSphereList.AddRange(x);
sortedSphereList.Sort(new Comparison<Brep>((f, g) => { return (f.GetVolume() < g.GetVolume()) ? -1 : 1; }));
int n = 0;
while(n < sortedSphereList.Count)
{
Brep b = sortedSphereList[n];
List<Point3d> points = new List<Point3d>();
points.AddRange(refPointList.FindAll((e) => b.IsPointInside(e, 0.1, true)));
fPoints.Add(points);
foreach (Point3d p in points)
{
refPointList.Remove(p);
}
n += 1;
}
A = fPoints[z];
}
// <Custom additional code>
List<Point3d> refPointList = new List<Point3d>();
List<Brep> sortedSphereList = new List<Brep>();
List<List<Point3d>> fPoints = new List<List<Point3d>>();
// </Custom additional code>
I haven't tried David's solution but this one is not really fast.
Thanks! I'll give this one a shot too, to see which works best. I'm running a brand new maxed out Dell Precision M6700 Laptop so i might be able to put some speed behind this. I'll let you know!
I tried with something similar - hp8770w ;)
In edited my reply I made the script shorter. I will also review both solutions later.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by