How can I find the max and min "diameters" of an unregular shape (like a circle)? The min diameter should be penpendicular to max one

Hi everyone,

I have a like-circle shape (a closed 2D curve), and I want to find two “diameters” of it. One is the max diameter, which means the max distance between two points on the curve; the other one (min diameter) is the distance perpendicular to the max dimameter, and should be max in this direction. The attached pic shows my demands.

My idea for the max diameter is that, I segament the curve into many points, then measure the distance between any two points then get the max one. However, I don’t know how I can ge the min diameter.

Any suggestions and help are so appreciated!

maxmindia.3dm (30.8 KB)

If you’re looking for an approximation, you can also compute the bounding box of the curve for a set of rotated frames, then pick the one with the biggest difference in width/height.

Thank you, David, for your suggestion.

Actually I need quite accurate results for comparison. And the work should be done in GH because there are many shapes for comparison.

… by who?

I mean even your first idea, on the main post, could be a way, but have you made some attempt in grasshopper? Can you attach it here?
Also, the absolute min and max diameters of the curve might not be perpendicular each-other. If you need them to be perpendicular, then maybe one of the 2 is not really the extreme of the min/max possible.

Maybe you want to find the biggest “ratio” Dmax/Dmin ??

For a precise solution you could iterate through rough sampling, more precise sampling and lastly fine sampling, making on each step a “score” 2D graph and interpolating with a curve and working with it. (like using the derivative of a function to find its quad points)

You could do it with Galapagos like this. Here’s a version that is not through the center of the shape, and a version that is through the center of the shape. (19.0 KB)


David, I tried implementing your suggestion as follows but wonder if this qualifies as min/max “diameters”? Neither the edges nor the “centerlines” of the bounding box pass through the center. (12.9 KB)

And as @maje90 has noted, the notion that min/max “diameters” (passing through the center) will be at right angles doesn’t sound correct?

Here’s a different way: (they appear to be very close to 90 degrees apart?) (15.5 KB)

Woow…what a similar approach in formatting as @Joseph_Oster:slight_smile:

As @DavidRutten David suggested, i have used bounding box and Galapagos… (9.9 KB)

1 Like

Thank you Riccardo, for your reply.
I admit that I just have the idea for the max diam and haven’t tried it in GH. It’s my fault.
I think I have some unclear meaning of the “min” diametere. What I want is the diameter perpendicular to the max one, while it is not necessarily the minimum diameter.

Thank you so much, jaymezd, for your kind help! That’s really what I want. I will test it now.

Hi Joseph, thank you so much for your kind help. I need to try your code to understand it. The “min” diameter I mean should be perpendicular to max one, but maybe not the really minimum one.

Wow, Jakinta, that looks so cool!
I really need sometime to understand your method…

If you want min max distance from the center you can use evaluate curve and record point movements than choose the min max distance; increase step >more time>more precision
maybe someone can make it with python
Also the min distance is from the closest point (14.7 KB)

1 Like

Hi James, I just tried you code. You choose the middle of the max diameter as the location of the min diameter. But I don’t think it will ensure the min diameter has the max length in this direction.
Would you please offer me an explanation?

Here is a third method, not restricted to passing through the Area ‘C’ (Centroid, white ‘X’), that finds a slightly longer distance between two points on the curve. The min “diameter” is then derived by rotating the max line around its center point and is very slightly longer than the min from the previous method. (14.5 KB)

Now I wonder if there might be a shorter parallel line to this min? Actually, there are many, down to zero length, so let’s ask a different question: Where is the longest line perpendicular to the max length? Aha, I see you just asked the same thing. Here: (16.5 KB)

Hi Joseph, I tried both your code. I think the secode is better, however, for the min diameter it’d better not be stricted to the centroid.

Version ‘d’ gives the longest possible max diameter (20.1958601) and longest possible perpendicular to that (13.7781317).

P.S. Note that max increases to 20.1956077 when ‘Count’ = 430.

1 Like

Hi Joseph, your “d” code is perfect!! And compared to all the codes, this one is the most accurate and fast.
Thank you so much again for your kind help and patience, as you always do…

The explanation is that you were not clear in what you were asking for originally, so I did my best to guess at what you were after. The definition I provided to you would be really easy for you to edit to behave the way you want.

Thank you, jaymezd, for your explanation. I appologize that I was not clear for my idea…
Thank you again for your nice work and help!!

Hi Seghier, I downloaded three plug-in before I could use your code :slight_smile:. However, it’s still difficult for me to understand it. Could you pleae offer some instruciton?
Thanks again!