# Find (x, y) coordinate on circle intersecting rectangle with width x at an angle?

Given the following: What equation could calculate the (x, y) coordinates of the blue points of intersection between the circle and the yellow rectangle?

Expressing the circle using polar variables $\theta$ and $r$ (where $r$ is constant), we'll have \begin{align} x&=r+r\cos \theta\\ y&=-r+r\sin \theta \end{align}

If you draw a hypothetical line from the circle's center to one of the intersection points, you'll see the angle between this line and the $45^\circ$ line is $$\delta=\sin^{-1}\left(\frac{w}{2r}\right)$$ where $w$ is the width of the rectangle. Thus, the $\theta$ corresponding to the intersection points will be \begin{align} \theta&=-\frac{\pi}4\pm\delta\\ &=-\frac{\pi}4\pm\sin^{-1}\left(\frac{w}{2r}\right) \end{align}

You can now replace the $\theta$ in the first two equations to get $x$ and $y$ coordinates.

Note that the equation of the circle is $(x-r)^2+(y+r)^2=r^2$ and the equation of the sides of the rectangle(using $x_0$ for the breadth) is $x+y\pm\frac{x_0\sqrt2}{2}=0$, which comes from the fact that sides have slope of $-1$ and perpendicular distance of $x_0/2$ from the origin. You will get 4 intersection points choose accordingly.

Imagine drawing a line segment between those two blue dots. Its length will be $x$.

Then imagine drawing radii from the centre of the circle to the two dots. You will have created an isosceles triangle with sides $r$, $r$ and $x$. This isosceles triangle is divided into two right-angled triangles. The hypotenuse is $r$, let the angle at the centre be $\theta$ and the opposite side is $\frac x2$.

That means that $\sin \theta = \frac x {2r} \Rightarrow \theta = \sin^{-1}\left( \frac x {2r} \right)$.

Using @Babak's notation:

\begin{align} x&=r+r\cos \theta\\ y&=-r+r\sin \theta \end{align}

The blue points are found by rotating by angle $\theta$ clockwise and anticlockwise from $-45^{\circ}$

So set $\theta_1=-45^{\circ} +\sin^{-1}\left( \frac x {2r} \right)$ and $\theta_2=-45^{\circ} -\sin^{-1}\left( \frac x {2r} \right)$ and work out:

\begin{align} x_1&=r+r\cos \theta_1\\ y_1&=-r+r\sin \theta_1 \end{align}

\begin{align} x_2&=r+r\cos \theta_2\\ y_2&=-r+r\sin \theta_2 \end{align}

• "The blue points are found by rotating by angle θ clockwise and anticlockwise from 45..." Can you illustrate? Not sure I know how to do this. Jan 4, 2017 at 23:13