Get a right triangle
The hypotenuse is r and the upper right angle is (R-y).
pythagorean theorem
There is r 2 = (r-y) 2+x 2.
So x = radical sign (r 2-(r-y) 2)