algorithmic modeling for Rhino
Well friends,
Imagine a brep with a single face (a trimmed surface) that "approximates" some tensile membrane that may look like this image attached (prior sending stuff to Kangaroo). Not my project: in fact some friend's friend asked that in order to send a collection of random "anchor" points to Kangaroo and ... blah blah.
The requirement is to find anchor points by (a) creating a random set of points (within the projected face in a given plane, in most of cases the global xy) and then (b) "culling" them as follows:
(b.1) no two points are closer than MinDistance.
So this script attempts to "cull" randomly placed points that satisfy(?) the MinMax criteria and do the rest. NOTE: points are few ... so don't stick to algorithm's efficiency.
2 questions for the willing gurus out there:
Script 1: this "cull" approach is rather wrong - I'm open to any suggestion.
Script 2: change the MaxDist value and observe the script turning from red to OK status. Why?
NOTE: GH fails to internalize stuff quite frequently. If this is the case, use Rhino file
best, Peter
Tags:
Hmm... the algorithm works correctly (some null testing etc. is missing...) but maybe I misunderstood the problem.
The algorithm starts with the first point in the set (green) and searches all untested points within the given interval (cyan):
It removes the points that are to close to each other (gray) and adds the rest to the final set:
It repeats the hole thing with the last added points:
After 7 iteration steps there are no untested points (pink) that matches the criterion:
All of them are too far away or too close to already added points.
The algorithm gives you different results depending on the order of the points (I don't think you can avoid this). Maybe you can filter more points with a different order.
Cheers!
Hmm... so the solution could be finding "regions/sets" of points ("clusters" if I may use the term) that satisfy the min/max criterion: meaning re-setting the green (start) point from the pink set until all pinks are tested.
You can do that but that means that you drop the max criterion (and in some cases also the min criterion...). Then the final set will contain points where the distance to the nearest neighbor is greater than the given max value.
Instead of filtering points from a random set you maybe can create your own point generator that takes regard of the min-max criterion.
Well...that's really cool (I like the filter thing : better safe than sorry, he he)
And since the case is resolved (grazie mille : if you plan vacations in Greece, a ballistic Ducati 1199 is waiting for you) I was thinking the following :
Since my initial stupid approach actually creates sets of (potentially "isolated" ) points ... what about storing them in branches (per iteration) and then testing branch x against the rest about if there's any point in any other branch == with a point of the branch x (if yes addrange, remove and create a sum of the 2 sets etc etc). That way we could create "islands" (sets) of OK points potentially isolated (violating the initial requirement - but just for the shake of it).
Of course this is pointless ... but because of that it's worth doing it.
best, Peter
OK, the last remaining thing:
In order to make this query to work :
we need a faceC of type curve, right?
so the final question is : given the fact that the BrepFace shown has holes (inner loops) how we can do it? (test shown turns GH script red by attempting to declare a curve as union (of Array of curves)).
Since I never design things with Rhino, the following "terminology" may be totally wrong: we need a difference between BrepFace Outer Loop and Inner Loops - doe's such "curve" type exist (a region ???) - and if it is does can accept the .Contains(point)?
You're welcome!
Maybe you can change the type of "bounds" to Brep. Then you can use the yellow projection as "bounds" and check if a point lies on the Brep with something like this:
.Where(p => bounds.ClosestPoint(p).DistanceTo(p) < 1e-12)
And yes: With some improvements you can use the algorithm to create "islands" of valid points.
Thomas
bounds.ClosestPoint(p, out u, out v) is bool
Arrived in the known jelly fish mind state > close computer > start the Ducati.
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