Test each polygon-segment for adjacency

Hey, I have a polygon A in the center of a couple of other polygons. I want to test each segment of polygon A if it is completly adjacent to at least one of a list of other (closed) polygons. I´ve tried to test the adjacency by using the start and endpoint of each segment and calculate the distance to each other polygon. Unfortunately I cant get the tree structure to work. The goal would be to generate a list for each segment saying if it is adjacent to at least one of the surrounding polygons.

So lets say the inner polygon has 25 segments. The list would then contain 25 true/false values. Thanks in advance!

question.gh (10.5 KB)


Your ‘Adjacent Polygons’ are not internalized. Not sure what “completely adjacent” means?

You want to check only one polygon (at a time) against a list of others? My full reply just got lost…

adjacent_crvs_2023Mar15a.gh (12.1 KB)

P.S. This is the part you want:

adjacent_crvs_2023Mar15b.gh (13.0 KB)

Sometimes checking for zero distance doesn’t work and you may need to allow VERY SMALL values to count as zero. Less than 0.00001, for example.

1 Like

Hey Joseph, sorry for not internalizing the data. You got it correct. Thanks for your definition. Works perfectly.

This one is a little better as it uses a cluster I wrote, isEqual, to test for equality within a tolerance value. Sometimes that makes a difference.

adjacent_crvs_2023Mar16a.gh (24.9 KB)

P.S. I just noticed though that both include “corners” (vertices) that are adjacent.

1 Like

I like this one better. It explodes the perimeter curves (you were on the right track) and uses Kangaroo’s dupLn (Remove Duplicate Lines) so surfaces with only common vertices are ignored.

adjacent_crvs_2023Mar16b.gh (27.7 KB)

Post your test data?

I see, this one selects only the adjacent polygons that share a complete segment with the inner polygon. In fact I need it the other way round: Check for each segment of the inner polygon if it lays completly on one of the surrounding polygons. Your previous definition were perfect :slight_smile: Thanks!

Post your test data? (I shouldn’t have to ask at all, let alone three times!)

1 Like

sure, sorry sir. I didn´t tought it might be for your interest anymore…Here the testdata:
testdata_for_joseph.gh (11.0 KB)

Edit: And by “completly on the polygon” I mean that each endpoint of a segment is on one of the surrounding polygons.

I lose interest when you call me “sir”.
Test data is useful for anyone looking at the problem, not just me.

It looks like my last version (‘b’) works perfectly. What’s the problem? Version ‘a’ works the same way with your test geometry but I showed examples where it fails, which is why I wrote version ‘b’.

adjacent_crvs_2023Mar16c.gh (24.5 KB)

1 Like

Thanks again. I need an answer to a different question! Your Version C gives me a list of polygons that are adjacent to the inner polygon (5 Polygons). Thanks! But I need to test each of the segments of the inner poylgon (25 segments) if they are on one of the surrounding polygons. So the definition needs to generate a list of 25 true OR false values!

But it´s fine. I came up with a very simple solution which is also embarassing for me. I´m so dumb :smiley: