# Is there a closed-form solution for the distance to the origin from the midpoint of a line connecting a point on an arc and a point on a tangent?

I have a fixed-length line $$EF$$, whose endpoints run along a track consisting of two straight segments joined by an arc. I'd like to create a polar equation describing the location of the centerpoint of $$EF$$ as it travels along the track, but I'm having issues finding closed-form solutions for certain areas of the track. Here, the arc $$BC$$ has radius $$R$$ and angle $$\alpha$$, $$DB$$ and $$DC$$ are tangent to the arc $$BC$$ at $$B$$ and $$C$$, respectively, the length of $$EF$$ is $$g$$, and $$G$$ is the midpoint of $$EF$$.

My current approach is to create a piecewise equation giving the length of $$AG$$ for a given value of $$\theta$$. For values of theta such that $$E$$ and $$F$$ are both either inside the arc or outside the arc, the equations are fairly straightforward, but I'm having issues finding something that works when one of the two points are on the arc.

What I have so far is:

$$r(\theta) = \begin{cases} \sqrt{R^2 + (R\ \tan(\theta_{\text{arc_min}} - \theta))^2} & \theta_{\text{min}} & \leq \theta & < \theta_{\text{all_out_min}} \\ ? & \theta_{\text{all_out_min}} & \leq \theta & < \theta_{\text{all_in_min}} \\ \sqrt{R^2 - \left( \frac{g}{2} \right)^2} & \theta_{\text{all_in_min}} & \leq \theta & \leq \theta_{\text{all_in_max}} \\ ? & \theta_{\text{all_in_max}} & < \theta & \leq \theta_{\text{all_out_max}} \\ \sqrt{R^2 + (R\ \tan(\theta - \theta_{\text{arc_max}}))^2} & \theta_{\text{all_out_max}} & < \theta & \leq \theta_{\text{max}} \end{cases}$$

The variable naming leaves something to be desired, but in any case:

• $$\theta_{\text{arc_min}}$$ is the angle at which the arc starts
• $$\theta_{\text{arc_max}}$$ is the angle at which the arc ends
• $$\theta_{\text{all_out_min}} = \theta_{\text{arc_min}} - \arctan\frac{g/2}{R}$$ is the largest angle less than $$\pi$$ where both $$E$$ and $$F$$ are outside the arc
• $$\theta_{\text{all_out_max}} = \theta_{\text{arc_max}} + \arctan \frac{g/2}{R}$$ is the smallest angle greater than $$\pi$$ where both $$E$$ and $$F$$ are outside the arc
• $$\theta_{\text{all_in_min}} = \theta_{\text{arc_min}} + \arcsin \frac{g/2}{R}$$ is the largest angle less than $$\pi$$ where both $$E$$ and $$F$$ are inside the arc
• $$\theta_{\text{all_in_max}} = \theta_{\text{arc_max}} - \arcsin \frac{g/2}{R}$$ is the smallest angle greater than $$\pi$$ where both $$E$$ and $$F$$ are inside the arc

My attempts at solving this problem all seem to run into the same issue, where there just doesn't seem to be enough information to get a useful result. I know the lengths of $$FG$$ and $$GE$$, as well as the distance $$AF$$, but that only gives me two sides of a triangle, and other approaches don't seem to yield better results. I'm going with an iterative solver for now, but a more elegant (and less likely to be buggy) solution would be preferable.

Does a closed-form solution exist? And if so, how would it be derived?

## 1 Answer

It might not be possible to do better than an implicit equation. Here's what I can come up with.

Let's introduce new parameters for the coordinates of $$E$$ and $$F$$:

• $$E=(x,y)$$
• $$F=(s,t)$$

We get three equations relating these parameters:

• $$s^2+t^2=R^2$$
• $$(x-s)^2+(y-t)^2=g^2$$
• $$y=x-\sqrt{2} R$$

You can eliminate $$y$$ to rewrite the second equation, getting

• $$s^2+t^2=R^2$$
• $$(x-s)^2 + (x - \sqrt{2} R - t)^2 = g^2$$

In principle, these two equations can be solved for $$s,t$$ as functions of $$x$$, say $$s = \beta(x)$$ and $$t = \gamma(x)$$. But it'll be messy at best! For instance, you can solve the first equation for $$s = \sqrt{R^2-t^2}$$, then substitute into the second equation. You'll get some algebraic equation for $$t$$ which you can attempt to solve for $$t$$. In principle this equation can be solved for $$t$$: you isolate the radical, get rid of the radical by squaring, and then I think you'll get a 4th degree polynomial in $$t$$ for which there's a known formula for the roots. But it'll be pretty horrible.

But to continue anyway, from the midpoint formula we have $$G = \left( \frac{x+s}{2}, \frac{y+t}{2} \right) = \left( \frac{x + \beta(x)}{2}, \frac{x - \sqrt{2} R + \gamma(x)}{2} \right)$$ Also, $$\tan(\theta) = \frac{x - \sqrt{2} R + \gamma(x)}{x+\beta(x)}$$ If we could solve the last equation for $$x = \delta(\theta)$$ then we would be done, by plugging that function into the formula for $$G$$ (and then writing down $$r(\theta) = |G|$$).

But $$\gamma$$ and $$\beta$$ are messy functions of $$x$$, and I suspect this cannot be solved so easily for $$x$$.

• Well, crap, reading your answer made me realize I accidentally overspecified my diagram, as the extent of the arc is some other known free parameter, and not known to be $90^{\circ}$. I'm not sure if it affects the overall idea of your answer, though, just the specific equation you initially had relating $x$ and $y$. Give me some time to digest it and see how it turns out. – awksp Nov 9 '18 at 18:59
• Also, did you mean $F = (s, t)$? – awksp Nov 9 '18 at 18:59
• Yes, $F=(s,t)$. And whatever parameter you want for that arc, it will just cause the formula $y = x - \sqrt{2} R$ to be replaced by some other specific linear formula $y = mx+b$, where $m,b$ are expressed in terms of your parameters. So that's not a serious issue. – Lee Mosher Nov 9 '18 at 19:09
• I've spent some time playing with your solution, and I think you're right; it's solvable in principle, but it's horrendously messy. I've been trying out the CAS functionality of Sympy and Sage because I don't trust myself to do the algebra correctly, and those start stumbling when I ask them to solve for $x$ in terms of $\theta$. I'll continue playing with the CAS systems, but I'll accept your answer because it seems to be the right way to go. Thank you for your help! – awksp Nov 12 '18 at 16:24