Given the ratios of distances from three corners of a rectangle, find the coordinates of a point with said ratios.

523 Views Asked by At

Ratio Problem

I think the picture can explain it better than words, but I'm wondering how to figure this out. Given three ratios of distances from corners, not lengths (in the picture I set the base, $base=1$, to be the distance from the top left corner, while the other two corners are of lengths $\alpha\cdot$$base$ and $\beta\cdot$$base$) and given the height $H$ and width $W$ of a rectangle, what are the coordinates of a point with said ratios? I'm sure the Apollonian Theorem comes into play, but I can't quite figure it out. Thanks!

1

There are 1 best solutions below

8
On

Segment $1$ and segment $\alpha$ create a circle of possibilities called the Circle of Apollonius, with endpoints of its diameter at $\frac{W}{1+\alpha}$ and $\frac{W}{1-\alpha}$. $\beta$ and $H$ work similarly. You can then intersect these circles to find two solutions.

To find points where we can be via $\alpha$ and $W$, we can use the distance formula from the two points $(0,0)$ and $(W,0)$:

$$ \begin{align} \alpha\sqrt{ \left(x^2 + y^2\right)} &= \sqrt{\left(x-W\right)^2 + y^2}\\ \alpha^2 \left(x^2 + y^2\right) &= \left(x-W\right)^2 + y^2\\ \alpha^2x^2 + \alpha^2y^2 &= x^2 - 2Wx + W^2 + y^2 \\ \left(\alpha^2-1\right)x^2 + \left(\alpha^2-1\right)y^2 + 2Wx &= W^2\\ x^2 + y^2 + \frac{2W}{\alpha^2-1}x &= \frac{W^2}{\alpha^2-1}\\ x^2 + \frac{2W}{\alpha^2-1}x + \left(\frac{W^2}{\alpha^2-1}\right)^2 + y^2 &= \frac{W^2}{\alpha^2-1} + \left(\frac{W}{\alpha^2-1}\right)^2\\ \left(x + \frac{W}{\alpha^2-1}\right)^2 + y^2 + &= \frac{\left(\alpha^2-1\right)W^2}{\left(\alpha^2-1\right)^2} + \frac{W^2}{\left(\alpha^2-1\right)^2}\\ \left(x - \frac{W}{1-\alpha^2}\right)^2 + y^2 &= \frac{\alpha^2W^2}{\left(\alpha^2-1\right)^2}\\ \left(x - \frac{W}{1-\alpha^2}\right)^2 + y^2 &= \left(\frac{\alpha W}{\alpha^2-1}\right)^2\\ \end{align}$$

So the candidate points form a circle centered at $A = \left(\frac{W}{1-\alpha^2}, 0\right)$ with radius $a = \pm\frac{\alpha W}{\alpha^2-1}$. We can do the same thing with $H$ and $\beta$ to get a second circle centered at $B = \left(0, \frac{H}{1-\beta^2}\right)$ with radius $b = \pm\frac{\beta H}{\beta^2-1}$.

Now, let's find the intersections of these circles.

First, we need the distance between the centers:

$$d=\sqrt{\left(\frac{W}{1-\alpha^2}\right)^2 + \left(\frac{H}{1-\beta^2}\right)^2}$$

Now, the intersection. I'll use circle $a$ as the first circle. At this point the calculations are getting a little too nasty, and I haven't found anything nice after here, so you'll just have to do the math by plugging previous results in:

The distance from $A$ to the segment between the two solution points is $u = \frac{d^2 + a^2 - b^2}{2d}$. The distance from the line between $A$ and $B$ to the solution points is $v = \sqrt{u^2 - a^2}$. A unit vector pointing from $A$ to $B$ is $U = \frac{B-A}{d}$. Then $V$ is a unit vector perpendicular to $U$ - just switch the coordinates and flip one's sign. Finally, we can find the (up to) two solution points:

$$P = A + uU \pm vV$$