Converting depth of irregular shape to equal given volume

49 Views Asked by At

I have a 3D shape with the following aerial view:

shape layout

Where $a\ b\ c\ d\ e$ are known integers. The shape has a depth $f$ and volume $v$.

The question is, given a required volume $V$ where $V<v$, to the nearest integer, how much of $a$ can be converted to depth $g$ starting from left to right where $g<f$ ?

What I've tried:

The first thing I tried was to calculate: $$\frac{v-V}{(b+e*\frac da)*(f-g)}$$

This gets pretty close but doesn't really work because it tries to flatten the shape to a rectangle which assumes the whole width will always be converted, which isn't necessarily the case.

I've tried a few other ways like converting all of the $a*b$ shape that can be converted first and then trying to add on the extra bit due to the $d*e$ shape but without any success.

1

There are 1 best solutions below

7
On BEST ANSWER

enter image description here

CASE 1: We start from the right. Let the length converted to $g$ be x. Subcase 1: $x\leq d$. The new volume will be $$x(b+e)g+(d-x)(b+e)f + (cbf)$$ $$=(b+e)(g-f)x+d(b+e)f+cbf$$ If we equate this with $V$, then we get the range of $V$ (Using $x\in [0,d]$): $(bd+ed+bc)f=v\geq V\geq d(b+e)g+bcf$.

For this case, $$x=\frac{V-(db+ed+cb)f}{(b+e)(g-f)}=\frac{v-V}{ (b+e)(f-g)}$$ which is pretty close to what you did.
Subcase 2: $x\geq d$. Then the new volume will be $$d(b+e)g +(x-d)bg+(a-x)bf.$$$$=b(g-f)x +abf-dbg+d(b+e)g$$$$=b(g-f)x +abf+deg=b(g-f)x+(v-def)+deg$$$$=b(g-f)x+v+de(g-f)=(bx+de)(g-f)+v$$ Thus, we get $x =\dfrac1b (\dfrac{v-V}{f-g}-de)$. Similarly, using $x\geq 0$, we can find the range of V achievable.
I now hope you can solve CASE 2 (Start from left) and its subcases ($x\leq c$ and $x\geq c$) by yourself by breaking the box into parts as shown above.