# Coordinates of the point on the circle inscribed in a square

I try to find a way to calculate coordinates of a point nested on a circle inscribed in a square. The available variables, are: 1) side length of the square = 100; 2) circle radius = 50; 3) angle (a) = 45 degrees, but it can vary (e.g. 21, 15.3, etc.)

What I'm looking for in the situation described above are X2 x and y coordinates on the given square.

I'm out of ideas, so I'll be appreciate for any help.

put your square in a cartesian coordinate system an compute the equation of the incircle in the form
$(x-x_M)^2+(y-y_M)^2=R^2$
$M(x_M,y_M)$ is the middlepoint of the incircle with the coordinates $x_M,y_M$

Hope the following illustration helps:-

If we choose as origin the bottom-left vertix, and call the radius with the letter $\ r$:

$\ X_{2}(c_{x},c_{y})\iff X_{2}(50+c,r-c)$, where $c=r \sin(45°)=\frac{r}{\sqrt2}$

Let the perpendicular from $X_2$ to $X_0X_1$ be $X$. Then $\cos a=X_0X/50$ and $\sin a=X_2X/50$. From the way you have defined the coordinates so that moving right increases the horizontal coordinate and moving down increases the vertical coordinate, the coordinates of $X_2$ are $$(50+50\cos a,50+50\sin a).$$

• Please forgive my ignorance, but why is the Y coordinate not 50 - 50 sin a? – Upper Stage Sep 22 '14 at 16:06

(This may be using a sledgehammer to crack a nut...)

$X_2$ can be interpreted as a clockwise rotation of $X_1$ around $X_0$ with an angle of $a$.

This can be expressed as a rotation matrix:

$$R(a)= \begin{bmatrix} +\cos a & -\sin a \\ +\sin a & +\cos a \\ \end{bmatrix}$$

If you multiply this matrix with a column vector, then the result is a clockwise (*) rotation of the vector by an angle $a$ around the origin $(0,0)$:

$$\begin{bmatrix} +\cos a & -\sin a \\ +\sin a & +\cos a \\ \end{bmatrix}\begin{bmatrix} x \\ y \\ \end{bmatrix} = (x \cos a - y \sin a, x \sin a + y \cos a)$$

But we do not want to rotate around $(0,0)$ but $X_0$, so we need a coordinate transformation where $X_0$ corresponds to $(0,0)$: $$\hat X_1 = X_1-X_0 = (100,50) - (50,50) = (50,0)$$

Now we rotate $\hat X_1$ using the matrix above: \begin{align} \hat X_2 & = (\hat X_{1x} \cos 45° - \hat X_{1y} \sin 45°, \hat X_{1x} \sin 45° + \hat X_{1y} \cos 45°) \\ & = (50 \cos 45° - 0 \sin 45°, 50 \sin 45° + 0 \cos 45°) \\ & = (50 \cos 45°, 50 \sin 45°) \\ & \approx (35.36, 35.36) \end{align}

And reverse the coordinate transformation: $$X_2 = \hat X_2 + X_0 \approx (85.36, 85.36)$$

By the way: Using homogenous coordinates, we could even combine all of this into a single transformation matrix.

(*) In this example, it's a clockwise rotation because the coordinate system is left-handed. In a right-handed system, it would be a counterclockwise rotation.