I am wrapping my head around a problem which might be easy to solve but my brain is not working anymore… :-) I am looking for the smallest bounding box around a given center position from a given spread of 2d vectors.

I guess all there’s left to do for tebjan’s solution to work is to also do a max/min check with the resulting two points PLUS the input coordinate itself

Maybe find the smallest box containing three points in an OcTree and test there distances from each other? Use FromPointCloud to make a bounding box (in 3D) or use Rectangle (JoinPoints) (in 2D)?

After having a chat with David it turned out the actual problem is a bit more complex and also needs to hold a state and cover some more cases … the solution is not unique to a random pointcloud and depends on the interaction with the system and how those coordinates move. We were kind of close to a solution though last night

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.