> Given a set of rectangles, is there an algorithm that enables to move
> them slightly so that none of them will overlap with others ?
> I need this to display text items on a map, and would need the
> rectangles not to be moved too far away from their original position.
> I presume this problem has already been encountered by somebody else,
> and that this algorithm is highly recursive...
> Thanks for any help, link or advice you could provide on this topic.
> Olivier Guillion
> Myriad software
> (please remove the word before .com to get my real address)
I actually solved a similar problem years ago, namely "optimal"
placement of GUI components within a window, one of the criteria being
no overlap. I tried several algorithms, simulated annealing gave the
best results, but was also the slowest. You could probably get away
with just adding a repulsive force between the rectangles, while at
the same time attracting them to the original position.
If there are just a few rectangles that overlap, you could just do an
exhaustive search around the initial position, as you know the final
position will not be much difefrent. Anyway, it seems that you should
start with defining a goodness criteria or cost function for your
problem, then try to optimize this.