2

So I wanted a quick confirmation if my thinking is correct. The particular problem I'm working on is a $2$D Bezier Curve, with at most $4$ control points and at a minimum of $2$ control points. The more general question (also I'm going to use the distance squared because it is cleaner to look at);

If given an arbitrary coordinate, $(x,y)$, and $2$ arbitrary functions, $F_x(t)$ and $F_y(t)$, with the distance squared being

$D(t)=(x-F_x(t))^2+(y-F_y(t))^2$

The first order derivative of that equation with respect to $t$ being

$D'(t)=2*(x-F_x(t))(-F_x'(t))+2*(y-Fy(t))(-Fy'(t))$

The second order derivative being; $D''(t)=2*(x-F_x(t))(-F''_x(t))+2*F'_x(t)^2+2*(y-F_y(t))(-F_y''(t))+2*F'_y(t)^2$

I should be able to use Newton's method of

$t_{n+1}=t_n-D'(t_n)/D''(t_n)$

to approximate the t with the minimum distance to $F_x(t)$ and $F_y(t)$, correct?

(Clamping on t as well from the range of $t\in\{0,1\}$)

2 Answers2

1

At the closest point $P$ on the curve, the tangent vector is perpendicular to the vector from $P$ to the reference point $(x,y)$. So, the dot product of these two vectors is zero. This gives you a polynomial equation of degree 5 in the curve parameter, $t$, which you can solve using your favorite root finder (Newton or otherwise).

bubba
  • 43,483
  • 3
  • 61
  • 122
0

Beware that the Newton's method may fail in different ways:

  • it can find a root outside the usefult range of $t$, $[0,1]$ (you also need to check the distance at the endpoints of the curve).

  • it can find a local minimum which is not the global one (depending on the starting point).

The true challenge is to isolate the correct root.

This link https://computingandrecording.wordpress.com/2017/03/20/closest-point-to-a-cubic-spline/ suggests using the Sturm's sequence method to do this.