A complete answer can be found herehere however in summary:
- [S] rotate the polygon to match one of its edges with X axis
- compute
minmax
of X and Y for vertices - this gives you a candidate for minimum area rectangle (MAR) or MBR
- store the area of (x2-x1)*(y2-y1)
- repeat from [S] for all edges
- find the minimum area which corresponds to MBR
- rotate found [[x1,y1],[x2,y2]] by -angle applied in [S]
Done.