Let say P is nearer to BC of the equilateral $\triangle ABC$ with sides $= d$. If $G$ is the centroid, then $BG = h$, a known quantity.
In $\triangle APB$, $\theta$ is known because $\alpha$ and $\beta$ are known. Applying sine law to it, we can find $PB$.
In $\triangle BGP$, $GP$ can be found by applying cosine law to it.
In case “the angles made by lines going through R and each vertex A, B, C of the triangle” means $\theta$ and $\rho$ are known instead. See the second figure.
Apply sine law to $\triangle ACR$, we have $\dfrac {AR}{\sin (60^0 + \lambda)} = \dfrac {d}{\sin \rho}$
Similarly, from $\triangle ABR$, we have $\dfrac {AR}{\sin (60^0 + \beta)} = \dfrac {d}{\sin \theta}$
Cancelling AP and d from the two equations, we get
$\dfrac {\sin (60^0 + \beta)}{\sin (60^0 + \lambda)} = \dfrac {\sin \theta}{\sin \rho}$
$\dfrac {\sin (60^0 + \beta)}{\sin (60^0 + 180^0 - \beta - \theta - \rho)} = \dfrac {\sin \theta}{\sin \rho}$
$\dfrac {\sin (60^0 + \beta)}{\sin (\beta + \theta + \rho – 60^0)} = \dfrac {\sin \theta}{\sin \rho}$
The last equation contains only one unknown ($\beta$) should be solvable. Once it is known, $\alpha$ is also known. This is exactly case-1.
Consider the below diagram:
Now, let $\alpha$ = CA
Also notice thata triangle ACD, DFG are simiar, both have 90 degree angles and $\angle FGD = \angle CGA$.
Hence $\frac{CA}{FD} = \frac{CG}{GD}$
The equation of the circle is:
$$x^2+y^2=r^2 $$
where r is the radius of the circle
Now if $\angle ACG = \alpha$, the equation of the line CG is,
$$y = tan(\alpha)(x+b)$$
Here b is the length of CA.
If we substitute this into the equation of our circle, and solve the quadratic equation, we get:
$$x = \frac{ \pm \sqrt{-b^2 tan^2(a) + r^2 tan^2(a) + r^2} - b .tan^2(a)}{tan^2(a) + 1} $$
Consider only the positive case,
Hence we now know what the value of $FD$ is, also $CG = \frac{b}{\cos{(\alpha)}}$
Due to simlarity,
$$\frac{CG}{CA}=\frac{GD}{FD}$$
So,
$$GD = \frac{CG.FD}{CA} = \frac{\frac{b}{\cos{(\alpha)}}.\frac{ \sqrt{-b^2 tan^2(a) + r^2 tan^2(a) + r^2} - b .tan^2(a)}{tan^2(a) + 1}}{b} $$
Now,$$ CD = CG+GD = \frac{b}{\cos{(\alpha)}}.(1+\frac{\frac{ \sqrt{-b^2 tan^2(a) + r^2 tan^2(a) + r^2} - b .tan^2(a)}{tan^2(a) + 1}}{b})$$
To test this, let's try the diagram,
$$\alpha = 20.1669886607522$$
$$b = 3$$
$$r = 2$$
Substituting this into the equation,
Which is accurate.
For your question, all you would need to do is take CA = half the width of the rectangle, $\alpha$ as 90-the alpha in your pic, r as the radius.
The equation can be simplified to:
$$ CD = \cos{\alpha} . (b+\sqrt{r^2+(r-b)(r+b) \tan^2({\alpha})})$$
This works for the opposite side too:
Now, for the general equation for any angle,
$$\theta = \tan^{-1}(\frac{a}{2r})$$
$a$ is the width of the rectangle of the capsule
$r$ is the radius of the semi-circles
$b = a/2$
$\beta = 90 - \alpha $
$$
z = \left\{
\begin{array}{ll}
|\cos{\beta} . (b+\sqrt{r^2+(r-b)(r+b) \tan^2({\beta})})| & \theta \leq \alpha \leq 180- \theta, 180+ \theta \leq \alpha \leq 360 - \theta \\
|\frac{r}{cos(\alpha)}| & \text{for all other } \alpha \\
\end{array}
\right.
$$
Best Answer
For simplicity, assume the circumradius of the polygon is $1$. The inradius of the polygon is $r=\cos\frac\pi n$.
Suppose your ray is at some angle $\theta$ from an inradius, and that it hits the polygon at a distance $d$. We then have $\cos\theta=\frac rd$, so
$$d=\frac r{\cos\theta}=\frac{\cos\frac\pi n}{\cos\theta}$$
as illustrated below:
$\hskip{3cm}$