Finding x/y translation between two parametric curves with partial overlap

80 Views Asked by At

I have two parametric curves $\mathbf{c}_1 = (x_1(u), y_1(u))$ and $\mathbf{c}_2 = (x_2(v), y_2(v))$ which are defined for $u,v\in[0, 1]$.

Assuming one curve (say $\mathbf{c}_2$) is a translated version of the other but may only partially overlap, I'm trying to find the offsets $\Delta x, \Delta y$ between the two. In other words $x_1(u) = x_2(v) + \Delta x$ and $y_1(u) = y_2(v) + \Delta y$, where $x_2(v) \subseteq x_1(u)$ and $y_2(v) \subseteq y_1(u)$.

Example curves.

If there are multiple solutions, then I'm interested in the one that minimizes $\Delta x, \Delta y$.

I tried formulating it like this, but it doesn't seem correct (nor practical):

$\Delta x, \Delta y = \underset{\Delta x, \Delta y}{\mathrm{argmin}} \int \int ||\mathbf{c}_1(u) - \mathbf{c}_2(v) - \mathbf{\Delta}||^2 du\,dv$

Any ideas? BTW in my case all functions are actually polynomial splines.

1

There are 1 best solutions below

0
On

A rough outline, which ignores some corner cases and other details.

The key idea is that if one curve is a translate of the other, there will be places where their derivative vectors are parallel, and we can use these matching derivative vectors to understand the correspondence between the two curves.

Let's suppose that $c_2$ is shorter than $c_1$, as in your picture, which means that $c_2(I)$ is a subset of some translated copy of $c_1(I)$. Here $I = [0,1]$.

Let $w_0 = c_2'(0)$ be the tangent vector at the start of $c_2$. Find all parameter values $s$ such that $c_1'(s)$ is parallel to $w_0$. If $c_1$ is a cubic spline (for example), there can be at most two such $s$ values on each of its cubic segments, and they're easy to find by solving quadratics. Whatever the degree of $c_1$, there are only finitely many such values $s$. Call them $s_1,\ldots, s_m$. Similarly, find all parameter values $t$ such that $c_1'(t)$ is parallel to $c_2'(1)$. Call these $t_1,\ldots,t_n$.

Now for some $i$ and $j$, it must be true that $c_2(I)$ is a translated copy of $c_1(s_i, t_j)$. We have reduced the problem to a study of a collection of $mn$ subsegments of $c_1$. Finding the right one in this collection should be fairly easy. Shout if you need more details.