I am trying to create a Semi-Circle menu in an app I am working on:
Examples:
I remember doing math problems like this in University, but cannot remember the approach.
Basically, I would like to calculate the length of the visible portion of circumference, which I will then use to determine how many sub-menu circle items can be placed and where to place them.
Nuggets of Knowledge:
- The radius of the inner circle can be varied
- The radius of the outer circle can be varied
- The center of the two circles is always in the same spot.
- The distance between the inner circle and the edge of the screen can be varied, but if it is in a corner, the distance between the two edges will always be equal.
- The sub-menu circle items (no examples in the pictures) will have their center on the circumference of the outer circle, they will be equidistance apart (distance can vary) with equal radiuses (but the radius set can vary).
I am not necessarily looking for an exact formula to do these calculations (although that would certainly be a big help if someone has one or derived one) but I am at least trying to get insight on how to proceed with these calculations.
EDIT: In the following scenario:
I won't care about the section in the corner. I would only care if the whole circle would be visible in this case and can actually write a pre-check in that instance.




You need to check cases. If the center of the two circles is (x,y), the radius of the outer circle is R and the size of the screen is defined by MinX, MinY, MaxX, MaxY, then you need to check if:
There are 9 cases:
a. None of them are true, in which case the circumference is $C=2\pi R$. (1 case)
b. Only one of them is true. (4 cases)
c.$1$ and $3$, or $1$ and $4$ is true. Or $2$ and $3$, or $2$ and $4$ is true. (4 cases)
Case b:
If only one border screen has been crossed by the outer circle, let $dz$ be a generic stand-in for the distance from the center of the circle to the border. If, for example, $x+R \gt MaxX$ then $dz = MaxX-x$.
We then have $$\cos (\alpha)= \frac{dz}{R}$$ or $$\alpha = \cos^{-1} (\frac{dz}{R})$$ and therefore $$ C=(2 \pi - 2 \alpha)R$$
Case c:
If the outer circle crosses two borders, we have the following situation:
Again, I'm using $dx$ and $dy$ in a generic manner. If, for example, $y-R \lt MinY$ was true, then $dy = y-MinY$. Same goes for $dx$. Hence $$\alpha = \cos^{-1} (\frac{dy}{R})$$ and $$\beta = \cos^{-1} (\frac{dx}{R})$$ and therefore $$ C=(2 \pi - \alpha - \beta - \frac{\pi}{2})R$$