I see what you're aiming to achieve, but I think this might be over-complicating? For the more advanced case where a simple [x y] with subsequent affine transform (as currently) is not sufficient, I would suggest an easier option for the advanced user to make specific patterns would be to use an [x y] with affine=off - still performing suitable H/W scaling and max circle size selection as before.jdaw1 wrote:The simple algorithm has the advantage of simplicity. Can better be done?jdaw1 wrote:The radius chosen, those of the new form are then moved along the straight line from (x y) to (x1 y1), as far as possible without crashing into another circle. This will be done pairwise, each circle being moved a proportion p along the line, p chosen to be the lesser of 1 and first crash. Each circle will be moved the least of its pairwise p’s. (This is robust and simple, but wouldn’t handle complicated sequences of possible collisions.)
As an example, let the pattern include [ ! [-1 0 0 0] [0 1 0 0] [0 -1 0 0] ! ], and that the ellipses include circles much closer to each other, such that the three circles shown aren’t initially touching, and by a good margin. Then there are multiple solutions: for example, any of the three could land at (0, 0). And what about [ ! [-1 0 0 0] [0 2 0 0] [0 -1 0 0] ! ]?
Algorithm suggestions welcomed.
In the example we've been using, you could move from the following with affine=on which creates the pattern with four regular along the top:
[ [0 4]; [2 4]; [4 4]; [6 4]; [0 2]; [3 2]; [6 2]; [0 0]; [3 0]; [6 0]; ];
to using the following with affine=off which would keep the required pair together.
[ [0 4]; [2.5 4]; [4.5 4]; [7 4]; [0 2]; [3.5 2]; [7 2]; [0 0]; [3.5 0]; [7 0]; ];
(or scaled up by 10 if we're only allowed to use integers, you get the idea).
This would then seem straightforward to use for any unusual bespoke patterns required?