algorithmic modeling for Rhino
ok I tried some C# code but it seems to have issues as if the IsPointInside is not working right... see attached code
Wait a minute:
Do you want in fact to create some sort of pair prox connections ? (from a given pt in List1 connect to the closest in List2).
Or (alter ego) sample in a DataTree these pairs etc etc.
Used the fastest way ... notify if you want lot's of slower ones (LINQ and the likes).
see attached
Hi Peter... thanx for looking into my problem - have come across your solutions for others before - Kudos... You are right that I want to pair the points closest to one another. I used your solution and attempted to sort the points based on the lines drawn between them, but they are still not the same... I tried to use the spheres and IsPointInside because what happens if more then 1 line have the same lenght?
Thank you,
Oliver
Er ...
First things first:
1. If you want to sort the master List1 (or the other) ... well you should FIRST sort the List:
Due to the topology I would strongly suggest some "radial" (so to speak) sort using the "centroid" (ditto) point from List1 as the apex point for the vector angle calculations (with regard some user defined ref Vector and plane).
Notify if you want a Function that does that ... or describe what "sort" means to you.
2 Then do the prox pairs sampling.
thanx Peter...
That's why I thought using sphere is the way to go.
with sorting I mean I need the point pairs to have the same index within a list.
I have 176 spheres each containing 2 points. These 2 points are from 2 lists - one from each - the 2 points do not have the same index in their lists.
I take a sphere check against all points from list 1 to see if it is inside. If yes I stick it into a new list1.
I take the same spheres check against all points from list 2 to see if it is inside. If yes I stick in to a new list2.
these 2 list should now have the point pairs having the same index - right???
List<Point3d> sortedPoints = new List<Point3d>();
List<Brep> brepList = new List<Brep>();
foreach (var sphere in spheres)
{
foreach (var point in points)
{
if (sphere.IsPointInside(point, 0, true))
{
sortedPoints.Add(point);
brepList.Add(sphere);
}
}
}
Well ... don't panic: it's VERY simple:
Leaving sorting List1 aside (Easy: I'll prepare "some" ways ASAP) IF we sample (during the pair matching loop) the current point AND the prox point into a DataTree (with specific order: first the current , then the prox) ... AND THEN split the Tree into 2 ... well the Columbus egg or what?
Of course instead we could sample (during the pair matching loop) the current into a newList1 and the prox into a newList2 and have the very same effect: pairs with THE SAME indices. But a DataTree is more "mysterious" ... therefore preferable, he he (what about having more Lists in mind?: "prox" triads/quads and the likes).
elementary my dear Watson.
But the main point here is not that: it's worth examining various prox finding methods (say for a gazillion of points in List1/List2) and locate the fastest: that's a thingy worth the name I confess.
more soon
I concur Sherlock... I was just looking for a down and dirty solution for my problem - which I am trying to solve for 2 days now. I could have just referenced each point by hand - but that would just not be the grasshopper way.... Oliver
Get the index matching thingy (2 Lists would be more elegant I confess, he he) and allow me a couple of minutes to mastermind 4 of the slowest pair matching methods known to man (in the Name of Science, what else?)
I'll be back, Arnie (Terminator 5)
And since you flirt with the Dark Side (the only side, mind) ... I've added some small challenge for your C# adventures:
modify the first thingy, make 2 squeezed eggs, trim them (or not), populate them with random points ... and then do the sort, the pairing or ... er .... some other more proper stuff (if waves are around to catch).
I made small changes to your code and got exactly what I needed... I owe you a cold one... thank you thank you and did i mention thank you
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