0

Inspired by this question earlier today, I started wondering if it is possible to prescribe points (... or tangents... or higher order derivatives) to a Bezier curve and then to go backwards to solve for the "aiming points" $\bf P_k$.

$$\forall t \in[0,1] : B(t) = \sum_{k=0}^N{\bf P_k}\left(\begin{array}{c}N\\k\end{array}\right)t^k(1-t)^{N-k}$$

In other words if we have some set of $t$:s $\{t_k\}$ and corresponding vectors $\{{\bf v_k}\}$ so that :

$$\forall l,t_l,\{{\bf v_l}\} : B(t_l) = {\bf v_l}$$

can we solve for the $\bf P_k$ to satisfy this equation? Or in case it is unsolvable, can we minimize the error in some suitable sense?

Which methods exist to do this?

What I have realized so far is trivial is first and last point, they must trivially always be end-points $\bf P_0$ and $\bf P_N$

mathreadler
  • 25,824

1 Answers1

1

What you want is

$${\tiny{\begin{pmatrix}\textbf{v}_{1,x}\\\textbf{v}_{1,y}\\\textbf{v}_{1,z}\\\vdots\\\textbf{v}_{n,x}\\\textbf{v}_{n,y}\\\textbf{v}_{n,z}\end{pmatrix}}={\begin{pmatrix}\binom{N}{0}t_1^0(t_1^{N-0})& 0&0&\binom{N}{1}t_1^1(t_1^{N-1})&\ldots&0&\binom{N}{N}t_1^N(t_1^{N-N})&0&0 \\ 0&\binom{N}{0}t_1^0(t_1^{N-0})& 0&0&\ldots&0&0&\binom{N}{N}t_1^N(t_1^{N-N})&0 \\ 0&0&\binom{N}{0}t_1^0(t_1^{N-0})& 0&\ldots&\binom{N}{N-1}t_1^0(t_1^{N-N+1})&0&0&\binom{N}{N}t_1^N(t_1^{N-N}) \\\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots \\\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots \\\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ \binom{N}{0}t_n^0(t_n^{N-0})& 0&0&\binom{N}{1}t_n^1(t_n^{N-1})&\ldots&0&\binom{N}{N}t_n^N(t_n^{N-N})&0&0 \\ 0&\binom{N}{0}t_n^0(t_n^{N-0})& 0&0&\ldots&0&0&\binom{N}{N}t_n^N(t_n^{N-N})&0 \\ 0&0&\binom{N}{0}t_n^0(t_n^{N-0})& 0&\ldots&\binom{N}{N-1}t_n^0(t_n^{N-N+1})&0&0&\binom{N}{N}t_n^N(t_n^{N-N})\end{pmatrix}}{\begin{pmatrix}\textbf{P}_{0,x}\\\textbf{P}_{0,y}\\\textbf{P}_{0,z}\\\vdots\\\textbf{P}_{N,x}\\\textbf{P}_{N,y}\\\textbf{P}_{N,z}\end{pmatrix}}}$$

The matrix is the design matrix needed for the least square parameter:
$\textbf{P}_{vec}=(M^TM)^{-1}M^T\textbf{v}_{vec}$

See https://en.wikipedia.org/wiki/Ordinary_least_squares

Note when fitting a bezier, it usually doesn't matter if your specified points denoted by $\textbf{v}$ occurs exactly at those $\textbf{t}$ values you gave. The real fun begins when you let the $t$-values vary only preserving the order. If that is done you get a closer fit than the ordinary least squares.

Even more fun will arise if you want to minimize an other error than the least square error.

Oppenede
  • 546
  • Nice answer, but the matrix is super big! Can't we express it more compactly somehow? – mathreadler Jun 22 '18 at 18:57
  • Normally, the (x, y, z) components of points will be separated to different columns so that the matrix will only be nxn instead of 3nx3n (where n is the number of points). – fang Jun 23 '18 at 20:22