Consider a rectangle with known width ($w$), height ($h$) and center ($R$). You can assume $w\geqslant h$.
A random point ($C$) is selected within the rectangle which is a distance of $x$ (horizontally) and $y$ (vertically) from $R$:
A circle is drawn centered at $C$ such that it completely overlaps the rectangle, but no more:
Is there a way to calculate the circle's radius $r$, given the known inputs $w$, $h$, $R$, $C$, $x$ and $y$?


Yes, there is. The radius of the circle is merely the length from $C$ to the vertex of the rectangle farthest away. Just draw a line from $C$ to this vertex and make that the hypotenuse of a right triangle. The legs of the triangle would be $|y|+\frac{h}2$, and $|x|+\frac{w}2$. Using the Pythagorean Theorem, this is $$\sqrt{({|y|+\frac{h}2})^2+({|x|+\frac{w}2})^2}$$.