Finding relationships

Hi

I am struggling with finding relationship between lines and use it to assign proper number in other lists (part of the project). Let me explain.
I have bunch of lines that are parallel to each other. Final goal is to create list with 7 branches where number “50” and “-50” are assigned according to position of these lines in referance to each other. Basicaly I am starting with list where I have 50 everywhere and now I need to replace some 50 with -50.
I need to check how the line is placed in referance to next line (in this case along X axis).
I have listed 8 options that are presnted below. Red line is a first line and blue is second.


First value in first branch and last value in last branch are always 50 (fixed).

Next thing I notice in my project is that 1st value in a branch is always opposite to second in branch above.

So basically, I need to assign values to all lines “1” because “0” will be defined by “1” above.
I tired to deconstruct end points, compare them with smaller and larget components and use some “Set intersection” but I am stuck here. I do not know if this is even right way.

Points.gh (17.1 KB)

couldn’t you sort lines by their mid points X value, then just partition list by 2 ?

Probably there is missunderstanding. Picture with lines, presents 8 posibilities of relationship between 2 lines. In the project I have 7 lines and I need to compare 1st to 2nd (8 posible relations) 2nd to 3rd ( 8 possible relations) etc. So in total 6 comparisions that I need to put in every branch under line “1” and then under “0” I need to put opposite to “1” in branch above.

Yes, I had completely misunderstood the problem :slight_smile: and I think I’m probably still misunderstanding it? :joy:

this is what I got:

the very first couple of lines looks like relation “-50”

so the first branch would be

{0}
item 0. 50 -> because the first value of first branch is always 50 regardless
item 1. -50 -> because we have found that this very relationship is called "-50"

then we swap to the second pair:

and we get:

{1}
item 0. 50 -> because the last item from previous branch was -50 so we put the opposite
item 1. 50 -> because we have found that this very relationship is called "50"

and so on for all the pairs?

but when you get to the very last pair you can also not calculate the relationship at all because

{last_branch}
item 0. XX -> this is the opposite of last item of previous branch
item 1. 50 -> very last item, this is always a 50 regardless

is all this correct? :upside_down_face:


if the above is correct, this is the first dirty sketch I came up with:


Points_inno.gh (25.4 KB)

the way to divide start/end point is brutally long and badly organized .____. just a sketch indeed

needless to say, you could compare vector angles instead of this Y coordinates… like drawing a Polyline that goes through all starts and another one through all ends, then explode it and check angle of each line with X axis to find out if it’s going up, down or staying horizontal… for sure there’s much space for improvement :smiley:

Get the attached and create more rules (and this and that).

Line_YEnd_Relations_V1A.gh (123.7 KB)

I don’t understand the problem.

@inno This is exactly what I need! :smiley: Only thing that is missing is last pair that doesn’t need to be calculated because item 0 is taken from previouse branch and last piece is always 50 :slight_smile: I will of course handle to add that part. You approach is way better then mine!
Thank you one more time! :smiley:

1 Like

I think this might take care of that?

Points_inno_Re.gh (23.7 KB)

first it calculates all “index = 1” values (B), which are the real calculated relations where very last item is replaced by a 1 (=50)

then it takes that list (B), deletes the last item, negates each remaining item, and adds a 1 (=50) in front of everything, in such a way:

{0}
0. 50 (fixed)
1. real relation between first and second line
{1}
0. negation of {0}(1)
1. real relation between second and third line

[...]

{n=last}
0. negation of {n-1}(1)
1. 50 (fixed)

it’s VERY EASY to get confused :upside_down_face:

Ok, I think I more less understand approach but I need to assign values to each line. Right now I have 7 lines and 6 branches. There is nothing to compare to last line but it is ok because last line is defined by previouse item and fixed 50. That is why I mentioned that this last branch is missing.

I’m sorry boys, but that seems like an unnecessarily complicated means of solving this problem. There’s no need to create extra geometry or use look-up tables. Essentially, you’re just comparing the Y domain of one line to the one of the line to the right of it and seeing if lies within that domain. If true, +50, else -50. Slap 50 onto the front an back, and ba-da-ding ba-da-boom… done:


Points_volker.gh (25.5 KB)

Edit: Oops…

but still…

Just to be clear: are these exact sets of line pairings the ones that will occur, or are they supposed to be categories?

categories

Ah… I finally understand.

Well, then this:


Points_volker3.gh (33.8 KB)

1 Like

I didn’t spend a single minute thinking wether a logic would be present to determine relations, your solution is beautiful :+1:

1 Like

@Volker_Rakow Wow, that is really nice and simple solution! I need to spend some time and go through it because I want to understand that your way :slight_smile: BIG thanks!

@inno Why thank you kind sir!

I appreciate that since I put some effort into keeping the script succinct. The logic seems to be that the relationship is a positive 50 when one of the endpoints of the blue line lies within (but not on the boundry of!) the Y domain of the red line. To work around the fact that domain bounds return “true” from Includes I had to set difference the bounding values from the test values for the domain inclusion test. This lead to the problem of the edge case where identical line being compared produce an empty set. That is what lead the myterious multiplication by list length at the end of the logic.

But I wouldn’t have been able to do it without you clarifying the task at hand, and in going through your script, I had the chance to familiarize myself with the Replace Text component, so thanks for that.