arc-arc intersection, arcs specified by endpoints and height

I need to compute the intersection(s) between two circular arcs. Each arc is specified by its endpoints and their height. The height is the perpendicular distance from the chord connecting the endpoints to the middle of the arc. I use this representation because it is numerically robust for very slightly bent arcs, as well as straight line segments, for which the height is zero. In these cases, representing an arc using the center of its circle could lead to the center being far far away from the endpoints of the arc, and hence, numerically unstable.

My question at the highest level is how I would go about computing the intersection points, given that the centers of the circles of the arcs cannot necessarily be computed robustly. At a lower level, I am wondering if there is a parameterization of an arc using only the information I have stated above (which does not include the circle center). Of course, keep in mind numerical robustness is my principal concern here; otherwise I would just do the naive thing and compute the circle center for all non-linear arcs and hope for the best.

Edit: Formula for computing center of circle of arcs:

Suppose the chord length is $2t$, and the height is $h$. The distance from the chord to the circle center is $c$, so that $r=h+c$. Then it follows that $c=(t^2-h^2)/2h$, which breaks down when $h$ is very small. Computing the location of the circle center is some simple vector arithmetic using the chord vector and its perpendicular.


Have you considered finding the intersections using an implicit form for the circles, $$\frac{x^2}{r^2} + \frac{y^2}{r^2} + ax + by + c = 0?$$ This representation doesn't have any coefficients that diverge as the circle approaches a straight line. To find intersections, you'll have to solve a quadratic equation whose leading coefficient could be zero or arbitrarily close to it, but the alternative form of the quadratic formula should be able to deal with that robustly.

You'll then have to do some jiggery-pokery to figure out whether the intersection points lie within the arcs. If the arc's bending angle is smaller than $\pi$, a projection onto the line joining the endpoints will suffice.

(Disclaimer: While all of this feels like it should work, I haven't analyzed it in any detail. Also, there could still be a problem when the circle is close to a line and you want the longer arc. But I can't imagine that's a case that would turn up in any practical application.)

Update: For a concrete example, here is the equation for a circular arc passing through the three points $(0,0)$, $(0.5, h)$, and $(1,0)$: $$\kappa^2 x^2 + \kappa^2 y^2 - \kappa^2 x - 2\eta y = 0,$$ where $$\begin{align}\kappa &= \frac{8h}{4h^2 + 1}, \\ \eta &= \frac{8h(4h^2-1)}{(4h^2+1)^2}.\end{align}$$ As you can see, the coefficients remain bounded as $h \to 0$.

Update 2: Wait, that equation becomes trivial if $h = 0$, which is bad. We really want something like $x^2/r + y^2/r + ax + by + c,$ i.e. multiply the previous expression through by $r$. Then for the same example, our equation becomes $$\kappa x^2 + \kappa y^2 - \kappa x - 2\eta' y = 0,$$ where $\eta' = (4h^2-1)/(4h^2+1)$. Here are some explicit values.

$h = 1/2$: $$2 x^2 + 2 y^2 - 2 x = 0,$$ $h = 0.01$: $$0.07997 x^2 + 0.07997 y^2 - 0.07997 x + 1.998 y = 0,$$ $h = 0$: $$2 y = 0.$$

By the way, in this format, the linear terms will always be simply $-2(x_0/r)x$ and $-2(y_0/r)y$, where the center of the circle is at $(x_0,y_0)$. As the center goes to infinity but the endpoints remain fixed, these coefficients remain bounded and nonzero (i.e. not both zero).


This is an interesting conundrum, and what I will suggest is just one possible approach, by no means a definitive answer. Perhaps what you could do is compute Bézier curve segment approximating your arcs, and then compute the intersection between Bézier segments. To compute the Bézier segment for an arc, you need the tangent vector at one endpoint (the tangent at the other endpoint is obtained by symmetry). So this approach reduces to finding a tangent angle at one endpoint.

Let the angle subtended by an arc at the circle center be $\theta$. If the arc's chord length is $c$ and its height $h$, then, if I've calculated correctly, $$\frac{\theta}{2} = \cos^{-1} \left( \frac{c^2 - 4h^2}{c^2+4h^2} \right) \;.$$ This avoids calculating the circle radius $r = (c^2 + 4h^2)/(8h)$. Now from $\theta$ you could compute the needed tangent angle, and from there a Bézier segment.

I have not analyzed this to see if it is indeed robust.