Find the position of a rectangle that touches a given circle when the direction of the line joining their centres are known.

79 Views Asked by At

I have a rectangle, the sides of which are parallel to $x\text{-}$ and $y\text{-axis}$. The length of the sides are known, i.e., width = $W$ and height = $H$. I also have a circle of radius $R$ with its centre at $\left(x, y\right)$.

Now, as shown in the sketches given below, I need to position the rectangle so that it touches the circle while the line joining their individual centres making a known angle of $\alpha$ with the positive $y\text{-axis}$.

I am unable to find a simple solution. If someone has an idea how to solve this problem, please share it with me. For programming, I am using the language Python.

First example

Second example