Grasshopper

algorithmic modeling for Rhino

Determine whether points are within a certain space

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?

Views: 2594

Replies to This Discussion

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.

Quick bump, im trying to get this research done fast. Like i said to tzin tzon, im not sure how to go about using the distance from my points to the center of the point cloud (0,0) to organize the points into seperate kists whike still maintaining parametric flexibility throught.

Lovely little problem. It certainly requires some really nifty tree-modification to get it done:

The logic is as follows:

  1. Figure out which brep in a list of breps is the first to contain any given point.
  2. The index of this brep then becomes a Tree Path (i.e. if index=2 then path = {2})
  3. Graft the original list of points and get the statistics of this grafted tree. We are interested in all the paths in this grafted tree (i.e. {0}, {1}, {2}, {3}, ..., {N} where N is the number of points-1).
  4. We then replace the existing sequential paths with the paths we created from the containment indices.

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

Attachments:
That sounds like exactly what ill need. I have just over 1300 points to crunch with this. Ill give it a shot tonight and let you know. Thanks so much!

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.

another method

Attachments:
David, that method worked perfectly. To give a bigger idea of what im doing with these points...i now have this hemisphere of points arranged into levels with the highest density at the center levels and the lowest density at the outermost. My next effort is tohave grasshopper draw a tree of curves between these points. Since most of the points are in the outermost level, the system sould be ideally suited for this. Any ideas on how to proceed?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service