Answer the question
In order to leave comments, you need to log in
What is the optimal algorithm for filling a canvas with circles?
Tell me the algorithm for filling the plane with circles, preferably with maximum density. Broke Google - nothing even close to find. In order for you to understand in more detail what it is about, look at Rabkin's tables for determining color blindness, where the entire field is densely filled with circles of different diameters and colors.
I draw all this, of course, in canvas. I came up with my own algorithm, but it came out too slow. a lot of iterations of coordinate calculation occurs in the main thread. If web workers had access to the canvas element, then I would not write here - albeit slowly, but the coordinates would be calculated in a separate thread, without causing the page to freeze for 15 seconds.
Answer the question
In order to leave comments, you need to log in
look at this.
paulbourke.net/texture_colour/randomtile
And this might come in handy
mrdoob.com/#/91/ball_pool
That is, it is necessary to fill the plane with circles of radius from p1 to p2 randomly?
Do I need to set the circles exactly or approximately? If so, I don't see a problem at all.
We select the region where we will throw, for it we calculate the squares of distances to neighboring circles, where we find an acceptable minimum - we throw there. If there are several minima, then it is random. For simplicity, we fill in the field from left to right (as long as there is a place, we throw it in a vertical strip, as the place ends, we move the strip to the right). The speed will be high (no need to count the root), you can generally count in integers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question