Multiple Curves intersections strategy

Hello,
I have been puzzling for days on how to group points by their line associations.
When I input both sets of horizontal and vertical curves in the multiple curves component I get a flat list of all intersection points for each path. I have tried using the iA and iB in order to associate and group each point for each curve respectively, but have no luck using ‘create set’, and member ‘index’. To further complicate the issue, certain points are a result of the intersection of two curves internally within either the horizontal path or vertical path respectively. If anyone could help me figure out how to attack this I would be grateful.

intersections.gh (8.1 KB)

[editing] I love you all :heart:

2 Likes

I knew you were going to reply to this, so I just waited.

Here is how I would do it:
intersections_solution.gh (14.1 KB)

You are losing your data structure in the multiple curves intersection, so I would cross-reference between each curve and find an intersection between each pair of curves.

For calculating the intersection points of multiple curves, I would more recommend using CCX (Curve | Curve), because its data structure is simpler and easier to understand. I’ve created an example based on the file you provided. I hope it will be helpful to you.

CCX.gh (12.5 KB)

And what will you do about the intersection of horizontal with horizontal lines?
You don’t really fully lose your data structure in multiple curves intersection, since you can retrieve the vertical and horizontal lines from their indices.

1 Like

Ah, I hadn’t spotted that indeed; In that case, I think this should solve the problem:


intersections_solution2.gh (15.9 KB)

1 Like

something went wrong with my edit :slight_smile: I’ll just leave that post there to not make too much confusion…

I would do like this, which is in the same flavor of Gijs’ solution:

where the tree structure of the final output of points is like this:

so for instance {2;3;3;2} means: “2;3”=left group, vertical at index 3, with horizontal at index 2

intersections_Re.gh (15.9 KB)

just one thing, these two points are intersections between two same goups of horizontal/vertical curves, so they are not found with CCX because it only finds horizontal intersecting with verticals, not horizontals intersecting within other horizontals / verticals intersecting within other verticals:

Yeah, that’s sort of the trick of the whole thing.

1 Like

So, instead of delivering on what we think Andrew needs, I set out to create a script that delivers on what he asked:

intersections vr1.gh (27.7 KB)

@Gijs_Jonkheer This script continues from your first, but feeds a merged set of the horizontal and vertical lines into Cross Reference so that either the horizontal or vertical lines (depending on which of these two you chose to create a tree for) are compared against all lines for Curve Intersection. For this, the order of the merge and setting Cross Reference to “diagonal” is important. The tree is already created at the CCX; all that the rest of the script does is clean things up, so that the data tree is structured by the index of the horizontal/vertical curves, and that the intersection points are indexed sequentially on the curves.

2 Likes

…for me juggling with Datatrees with vanilla gh-components always feels a bit like alchemy.
here is a scripting solution.
I did not push it to the minimum (of lines) and added a few comments…

I kept the Stream Filter Data-Flipping…

intersections_00_tp.gh (14.8 KB)

kind regards - tom

2 Likes

This will be really useful for me to learn how to code because I know what it is supposed to do, and is not so hard a problem… I think.

not sure if this is a great coding-learning-example as it uses code not for a specific solution-strategy, but only to overcome gh’s limitations regarding the idea of mixing Data-Structure and logic.
The script mainly sorts some data to access Rhino.Geometry.Intersect.Intersections.CurveCurve (in one line) and then sorts the result back into a Datatree.
For most scripting components you will not to create a tree by yourself. I recommand to start with simple scripts where the accesslevel is “Item”.

Okay.