Finding the maximum distance in opposite sides of a polyline

please tell me with this question, there is a closed polyline, is it possible to somehow find the most distant opposite lines in it?


max distance.gh (7.3 KB)

Why isn’t it this? Your question needs to be defined in more detail. Grasshopper can’t guess which lines you’re talking about unless you just want to get the distance between two lines of a specific index (8-16; 3-13 in your image).

O88

1 Like

As Ftzuk mentioned, this is a bit of a manual approach if you are looking to connect segments (3)-(13) and segments (8)-(16), as they are not truly the max distance. In which case you can take this approach and manually chose which segments to evaluate and project the line along the X or Y axis.

If you are looking for the true “max distance on opposite sides” its a bit more complex and requires a different approach in which you would creating a set of all distances and only extract the longest. distance.

max distance.gh (19.5 KB)

1 Like

Brute force :exclamation: :wink: Though it quickly gets very slow as the div points go up. WARNING!


max distance_2024_Jul22a.gh (18.3 KB)

300 points is more accurate:


Easy enough to add all the perimeter discontinuity points to the div points… :thinking:

HEY :bangbang: In this case, if you replace divide curve with discontinuity points, the code is fast and more accurate!

max distance_2024_Jul22b.gh (18.4 KB)

3 Likes

Yeah that is essentially what I would do too!

OP would have to divide the segments and evaluate the distances between all points to determine the longest.

If they wanted to keep distances in the X-Y direction, they could splice our scripts together.

1 Like

It just came to me that you could first find the two curves which have the furthest distance between midpoints, then divide those two curves up instead of all the curves in the list :smiley:

… perhaps there are some edge cases where that would not work. I’m pondering how to acheive this with a less operationally intensive approach

2 Likes

Sounds good. I believe it’s this white group added to my version ‘22a’:


max distance_2024_Jul22c.gh (25.8 KB)

2 Likes