I have a list $W$, of (non intersecting) rectangles where $W \ni w = (x, y, \text{width}, \text{height})$. The list is increasingly sorted by $y$-coordinates.
Given an input rectangle $R$, I would like to know how much $R$ can grow (maintaining aspect ratio) without intersecting with any of the other rectangles.
An example:
Here $W=\{D, B, C\}$ where $D=(10, 2, 2, 8)$, .. and $R=(1, 1, 1, 1)$, so its aspect ratio is $\frac{w}{h}=1$. R can grow its width to 8, because at 9 it intersects with D, but the height is maximized at 6. Therefore R can grow up to 6 times before it intersects with any of the other rectangles.
I'd like this function (or algorithm) to return 6 as the result.
Right now I'm doing the brute force approach, that is grow R once, check for each $w\in W$ if $w \cap R = \emptyset$ and repeat until the intersection is non-empty.