C++ – How to find an arbitrarily oriented minimum bounding box in c++

cgeometry

So let's say I have a list of N pairs of positive long coordinates (points).
How do I find the smallest rectangle containing all of them?
The rectangle can also have floating coordinates and be rotated in any angle and further shrunk… Not just X, Y, Width and Height!

Just an image I found on the web...

I already know how to find the smallest polygon or not rotated rectangle, but it's not what I need…I wish to know how to find the arbitrarily oriented minimum bounding box.

Best Answer

See http://www.geometrictools.com/Source/ComputationalGeometry.html

The section "Minimum-area box" has various examples.

e.g.

Compute a minimum-area oriented box containing the specified points. The algorithm uses the rotating callipers method.

https://www.geometrictools.com/Samples/Geometrics.html#MinimumAreaBox2D

https://www.geometrictools.com/GTE/Mathematics/MinimumAreaBox2.h

Related Topic