I need to fit a globally smooth cubic b-spline to interpolate through some points, while approximating others (i.e., 3rd case):
As I understand it, given the above example, approximation would involve something like this:
Input: Set of data points {P0, P1, ..., P3}, degree=3, desired number of control points m
Output: Approximated control points {Q0, Q1, ..., Qm}
1. Generate knots vector U = {u0, u1, ..., u8}
2. For each data point Pi, compute the weight Wi
3. Formulate and solve the linear system of equations to compute the control points {Q0, Q1, ..., Qm}:
sum of (N(ui) * Wi * Pi) for i = 0 to n = Q(ui) for each u in U
4. Return the set of approximated control points {Q0, Q1, ..., Qm}
And interpolation would involve something like this:
Input: Set of control points {P0, P1, P2, P3}, degree=3, number of evaluation points m
Output: Interpolated points {Q0, Q1, Q2, ..., Qm}
1. Generate knots vector U = {u0, u1, ..., u8}
2. For each evaluation point u in U, compute the basis functions N(u)
3. For each evaluation point u, compute the interpolated point Q(u) as:
Q(u) = sum of (N(ui) * Pi) for i = 0 to 3
4. Return the set of interpolated points {Q0, Q1, ..., Qm}
How can I combine the above techniques, or modify either one of them, to accomplish a mixture of both curve approximation and interpolation?