I have a Big Rectangle (axis-oriented) containing a lot of Small Rectangles (with the same orientation of the parent and with a fixed size of 82x176 pixels).

Now I have a Small Rectangle which is outside and I have to put it inside the Big Rectangle such that it is: - Randomly placed; - Not overlapping other Small Rectangles unless necessary due to lack of space (and, in this case, with the minimum overlap).

The algorithm, which will be used multiple times during my code execution, also needs to include a good distibution so that Small Rectangles will be nicely dispersed around the center of the Big Rectangle and not all clumped into one corner.

Googling, I found several algorithms concerning rectangles packing, largest empty rectangle, random distributions... but nothing really addresses my requirements nor shows a good code implementation.

Does anyone have any good ideas (code or pseudo-code is better, if possible, as normally my brain crashes when I see maths formulas)?