The task is to find the area (length and width) of a rectangle describing a contour consisting of primitives (arcs and lines). I have the coordinates of the points forming these primitives (the red dots in the picture)
There are also coordinates of cents of arcs, but perhaps they are not needed now. I solved the problem according to the following algorithm:
- compiled segments of all points, that is, connected each point with each;
- searched among the segments those that are perpendicular to each other;
- Among the pairs of perpendicular segments, I found those with the greatest product. This was the width and length of the desired rectangle (and, consequently, the area).
This algorithm worked well for most figures, including the one shown in the first figure. But I ran into the figure from the second drawing:
It is clear that my algorithm did not work here. Width he chooses the right (bottom base), but the length is not, because there is no coordinate of the center of the lower base, so that it would be possible to construct a segment connecting the center of the lower base with the highest point.
There was an option to find the center of the lower base, but this option is only for the second pattern. And if the situation suddenly arises from Figure 3, the algorithm again becomes inoperative. Because the segment connecting the top point with the center of the bottom base will not be perpendicular to the bottom base.
Please tell me a version of the general algorithm for finding the length and width of the rectangle describing the contour.



