My “solution” above is probably wrong.
I think you need to precisely define what you need:
- (1) May the CenterPoint be on the border or not?
- (2) Define smallest. Is it about the area or the distance?
Let’s assume that the Centerpoint shall not be on the border. Then there are two possibilities to surround the Centerpoint
- (A) a point on left-top quadrant and a point on right-bottom quadrant OR
- (B) a point on left-bottom quadrant and a point on right-top quadrant.
Those quadrants are surrounding the Centerpoint.
You maybe could create 4 spreads (1 for each quadrant).
(A) If there is at least one point in left-top and at least one in right-bottom then this is an option. You start with those first points of those two quadrants. Let’s say it is not about the area, because you want to avoid very thin and wide rectangles. So let’s stick with the distance. For each quadrant you compute the one point with the smallest distance to the center independently. Now do the same for (B).
You now often have two solutions (A) and (B) that you need to compare and pick from.
Sorting into different quadrants very much goes into the answer Hayden provided.