I am trying to calculate the voxel size for a voxel grid which must enclose a $3$D object with real dimensions $\alpha$,$\beta$,$\gamma$ ($\ge 0$).
The amount of voxels may be at most $\theta$ (integer, $\gt 0$). The real cell size I am looking for is $\omega$ ($\gt 0$).
So I am looking to maximize the following function:
$$f(\omega) = \lceil {\frac {\alpha}\omega} \rceil \lceil {\frac {\beta}\omega} \rceil \lceil {\frac {\gamma}\omega} \rceil $$
Where
$$f(\omega) \le \theta$$
The dimensions ($\alpha, \beta, \gamma$) may be equal to $0$, but in this case I can just use a formula without the corresponding ceiled fraction.
Does anyone know if there is a way to calculate an exact or approximate answer to this ?
Thanks in advance for your help.
Cheers,
Ben
I would start by ignoring the ceilings. You can then write $$\frac {\alpha \beta \gamma}{\omega^3}=\theta\\\omega=\left(\frac {\alpha \beta \gamma}{\theta}\right)^{1/3}$$ This will be too small unless your dimensions are all multiples of the $\omega$ you find. Now compute the number of voxels in each dimension by $L=\lceil \frac \alpha \omega \rceil$ and the corresponding formulas in each other dimension, getting $H,W$. If you reduce each one by $1$ you will have $(L-1)(H-1)(W-1)$ voxels, which will be less than $\theta$, so there are eight possibilities for numbers of voxels in each dimension. Compute which ones have an acceptable number of voxels, the $\omega$ that corresponds to each, and take the smallest.