Drawing the longest line segment contained in an area
6 views (last 30 days)
Show older comments
Inside a rectangle, this line segment would be its diagonal.

Inside a circle, this line segment would be its diameter.

Inside a more "jagged" shape, it would be:

However, suppose we consider an irregular area, such as

The longest possible line segment that can be drawn would not be as intuitive any more. Is there any geometrical approach (hopefully an efficient one) which would allow us to determine this mentioned line segment for any (enclosed) areas, in general?
Just to clarify, the line segment in question is a straight line. The entire line segment must be contained within the area. It cannot cross the boundary.
The final result could be something like this.

Accepted Answer
Image Analyst
on 26 Dec 2017
Edited: Image Analyst
on 26 Dec 2017
My attached demo does almost that. It doesn't check though if the line goes outside the region. You'll have to test for that if you think that's a possibility. Basically uses bwboundaries() and then gets the distance between every pair of points.
0 Comments
More Answers (1)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!