Fitting
Least Square
Many implementations shown in NURBS book didn’t work, like knot_insert, knot_remove, degree_increase and degree_decrease.
Another approach was made to contour this problem, which is by using the Least Square method.
Note
Mathematically speaking, we use the Galerkin’s method, which reduces the integral of the residual square.
Formulation
Let \(\mathbf{C}\) and \(\mathbf{D}\) be two curves defined by
With respectivelly knot vectors \(\mathbf{U}\) and \(\mathbf{V}\)
The objective is to find the values of \(\mathbf{Q}\) such \(\mathbf{D}\) keeps as near as possible to \(\mathbf{C}\). It’s made by reducing the residual square \(J\)
With
Minimizing
Since \(J\) is convex, minimizing \(J\) is obtained by talking its gradient and setting it to zero
Now it depends only on the computation of the terms \([GG]\) and \([GF]\) and solving the linear system to find \(\mathbf{Q}^{\star}\) from \(\mathbf{P}\). It’s a linear transformation by using matrix \(T\):
Error
An important mesure is about the error, which is in fact the value of \(J_{min} = J\left(\mathbf{Q}^{\star}\right)\):
Expanding and simplifying we get
Essentially the error comes from the transcription from the set of basis functions \(\ \Upsilon_{U}\) to the other set of basis functions \(\Upsilon_{V}\). If \(\Upsilon_{U} \subset \Upsilon_{V}\), that means, the basis functions of \(\mathbf{D}\) describes completelly the basis functions of \(\mathbf{C}\), then the error is zero.
For example, if \(\mathbf{V}\) (knotvector from \(\mathbf{D}\)) is obtained from a knot_insert or degree_increase from \(\mathbf{U}\) (knotvector from \(\mathbf{C}\)), then \(\Upsilon_{U} \subset \Upsilon_{V}\) hence \(J\left(\mathbf{Q}^{\star}\right) = 0\).
But if \(\mathbf{V}\) is obtained from a knot_remove or degree_decrease from \(\mathbf{U}\), then \(\mathbf{D}\) may not be equal to \(\mathbf{C}\), giving a non-zero error.
Least Square with restrictions
Sometimes, it’s needed that the new curve (after transformation) interpolate exactly at some nodes. For example, the extremities points of a curve don’t move when applying knot_remove (left image bellow) or degree_decrease, while the standard least square given above would give a result like in the right figure.
Formulation
Let \(\mathbf{C}\) and \(\mathbf{D}\) be two curves defined by
With respectivelly knot vectors \(\mathbf{U}\) and \(\mathbf{V}\)
The objective is to find the values of \(\mathbf{Q}\) such \(\mathbf{D}\) keeps as near as possible to \(\mathbf{C}\) and satisfies the interpolation restrictions:
For \(1 \le k \le m\) nodes \(z_{i} \in \left[a, \ b\right]\)
The same way, we reduce the residual square \(J\), but we add lagrange multipliers \(\lambda\) related to constraint functions \(h(\mathbf{Q})\)
With
Minimizing
The same way as before, but with two variables
We mount the expanded matrix with these two equations
If it’s solvable (the matrix is not singular), it has the solution for \(\mathbf{Q}\):
For the error, the expression of the matrix in terms of basis matrix is too complex. We use the computed matrix \(\left[T\right]\) to this expression
Warning
Repeted nodes makes the expanded matrix become singular (det = 0)
Number rows |
\(k\) |
\(m\) |
\(n\) |
|---|---|---|---|
\(k\) |
\(LL\) |
\(G, LG\) |
\(F\) |
\(m\) |
\(QF\) |
\(GG, QG\) |
\(T, GF\) |
\(n\) |
\(E, FF\) |
Discrete Least Square
This type is used when you want to find \(\mathbf{D}(u)\) near \(\mathbf{C}(u)\), but you cannot express \(\mathbf{C}(u)\) as a linear combination of points and basis function.
That means, you want to find \(\mathbf{Q}\) from
\(m\) basis functions \(g\)
\(k\) nodes \(z_{i} \in \left[a, \ b\right]\)
\(k\) points \(\mathbf{Z}_{i} = \mathbf{C}(z_i)\)
Note
There are three cases for \(k\). The first one gives error
\(k < m\) is a under-determined problem which has no unique solution
\(k = m\) is a interpolation problem
\(k > m\) is a over-determined problem which we use the least squares method
Then, define the residual function \(J\) and get its minimum
We derivate and set it to zero
TO DO

