Draw part of circle

129 Views Asked by At

I am trying to draw the following part of circle on a mobile screen but I can't do the math properly.

enter image description here

Please, ignore the text.

The left top corner is (0, 0) and the right bottom corner is (w, h). The width of the circular part is w/2 which is half the screen width.

To acieve that I want to draw I a big circle out of screen and only a small part of it inside.

So, the required output variables are the center coordinates of the circle (x, y) and the circle radius.

Obviously the x coordinate will be negative and the y coordinate will be positive.

Fact: Apple devices have no screen width/2 equals to height. Observation: when the circular part width and height difference increases the circle radius increase exponantially.

Result of the accepted solution by Ethan Bolker: Two different device screens: enter image description here enter image description here

1

There are 1 best solutions below

3
On BEST ANSWER

In this picture

enter image description here

$PQ$ is the mean proportional between $AP$ and $PB$. That means $$ h^2 = \frac{w}{2}(2x + \frac{w}{2}) = wx + \frac{w^2}{4} $$ so $$ x = \frac{h^2 - w^2/4}{w}. $$

That should be enough information for you to compute the coordinates of $C$.