How do you rearrange an equation with the product of floor functions?

36 Views Asked by At

Edit: I spent some time trying to generalise this formula for any build plate $l$ and $w$ and have realised a very small error in one of the quadratic equations below which I will correct tomorrow because I've spent a whole 10h on this today...

I have come across an interesting problem whilst looking to estimate how many cylinders of equal radius I can fit on a 3D printer build platform.

As I was writing out this post I think I've managed to answer my own question. It's only taken me all day learning about floor functions...however, I would like to know if there is an easier way to do this or if I have massively over complicated things?

I'm aware of the circle packing problem and from my research (please correct me if I am wrong) there isn't a general solution for optimising the number of circles of radius $r$ that can fit in a rectangle with side lengths $x$ and $y$.

Instead, I have assumed that the circles tesselate in a repeating square pattern. Each circle requires $5 mm$ clearance from adjacent circles. The build platform is $250mm$ by $210mm$. Therefore the total number of samples $S_T$ can be described by:

$$ \bigg \lfloor \frac{250}{2r+10} \bigg \rfloor \times \bigg \lfloor \frac{210}{2r+10} \bigg \rfloor = S_T $$

I would like to rearrange this into an inequality with $r$ as the subject, so I can determine what range of circle radii are possible for a given $S_T$.

I started by substituting the terms: $$n=\lfloor x \rfloor = \bigg \lfloor \frac{210}{2r+10} \bigg \rfloor$$

$$\lfloor x \rfloor \times \bigg \lfloor \frac{25}{21} x \bigg \rfloor = S_T$$

$$\bigg \lfloor \frac{25}{21} x \bigg \rfloor = \frac{S_T}{n}$$

Where

$$n \leq x < n+1 $$

From this we can create the inequality:

$$ \frac{S_T}{n} \leq \frac{25}{21}x < \frac{S_T}{n}+1$$

$$ 21S_T \leq 25xn < 21(S_T + n)$$

And if we multiply $n \leq x < n+1 $ by $25n$:

$$ 25n^2 \leq 25xn < 25n^2 + 25n $$

These relationships also tell us that the following must be true:

$$21S_T<25n^2 +25n \;\;\wedge\;\; 25n^2<21(S_T +n)$$

Solving each inequality with the quadratic equation we can find inequalities for $n$ in terms of $S_T$. Also, let the number of samples be defined as $10 \leq S_T \leq 50$.

To satisfy $25n^2 +25n -21S_T>0$,

$$ n= \frac{-25 \pm \sqrt{25^2+2100S_T}}{50} $$

$$2.411\leq n_1\leq 6$$ $$-7\leq n_2 \leq -3.411$$

To satisfy $25n^2-21n-21S_T<0$,

$$ n= \frac{-25 \pm \sqrt{21^2+2100S_T}}{50} $$

$$2.429\leq n_1\leq 5.994$$ $$-6.994 \leq n_2 \leq -3.429$$

However, $$n \in \mathbb Z_{> 0}$$ Therefore: $$n=3,4,5$$

This gives:

$$\bigg \lfloor \frac{210}{2r+10} \bigg \rfloor = 3,4,5$$

So for any of the aforementioned values of $n$, the range of values for $r$ can be calculated with the inequality.

$$n\leq\frac{210}{2r+10}<n+1$$

Kind regards, Jamie