I am coding an implementation of Boolean operations on SVG paths, and need to solve the following problem:
Given two sequences of curves, determine whether the distance between their images never exceeds $\varepsilon$.
I can assume that my curves are specified as polynomials is Bernstein basis (aka Bezier curves) or in symmetric power basis. I also have arcs, but I can approximate them by Bernstein or S-basis polynomials. I only need an approximate result.
A curve is a function from $[0, 1]$ to $\mathbb{R}^2$. Importantly, I need to determine whether the images of curves are close, so I can't simply calculate a difference and test whether it never exceeds some threshold. My goal would be to compute the nearest distance from one curve to the other at every point, and verify that it never exceeds some threshold.
I can compute the nearest distance from the curve $C(t)$ to the point $p$ by calculating the polynomial $(C_x(t)-p_x)^2 + (C_y(t)-p_y)^2$ and finding its roots, but I don't know how to generalize this so that I can find a function that gives the nearest distance at every point of the other curve. If I had a function $D(t)$ that would give the distance between $C^1(t)$ and the nearest point on curve $C^2$, I could just check whether $D(t)$ never exceeds $\varepsilon$.
I do not want to find $s$, $t$ that minimize the distance between $C^1(t)$ and $C^2(s)$. I need to verify that for every possible $t$, the nearest point on $C^2$ is no further than $\varepsilon$ away.
Let $C=(C_x^i,C_y^i)$, $i=1,2$ be the two curves. To find the distance between them you must minimize $$ F(s,t)=\bigl(C_x^1(s)-C_x^2(t)\bigr)^2+\bigl(C_y^1(s)-C_y^2(t)\bigr)^2,\quad0\le s,t\le1. $$ Taking partial derivatives with respect to $s$ and $t$ and equating to $0$ we get a system of two equations and two unknowns: $$\begin{align} \bigl(C_x^1(s)-C_x^2(t)\bigr)(C_x^1)'(s)+\bigl(C_y^1(s)-C_y^2(t)\bigr)(C_y^1)'(s)&=0\\ \bigl(C_x^1(s)-C_x^2(t)\bigr)(C_x^2)'(t)+\bigl(C_y^1(s)-C_y^2(t)\bigr)(C_y^2)'(t)&=0 \end{align} $$ You must also consider the possibility that the minimum is achieved at a point where $s$ or $t$ equals $0$ or $1$.