Fitting controlpoints with least squares method.

fittingcontrolpoints(func, Ps::Tuple)

This function will calculate $\bm{a}_i$ to minimize the following integral.

\[\int_I \left\|f(t)-\sum_i B_{(i,p,k)}(t) \bm{a}_i\right\|^2 dt\]

Similarly, for the two-dimensional case, minimize the following integral.

\[\int_{I^1 \times I^2} \left\|f(t^1, t^2)-\sum_{i,j} B_{(i,p^1,k^1)}(t^1)B_{(j,p^2,k^2)}(t^2) \bm{a}_{ij}\right\|^2 dt^1dt^2\]

Currently, this function supports up to three dimensions.


julia> f(t) = SVector(cos(t),sin(t),t);

julia> P = BSplineSpace{3}(KnotVector(range(0,2π,30)) + 3*KnotVector([0,2π]));

julia> a = fittingcontrolpoints(f, P);

julia> M = BSplineManifold(a, P);

julia> norm(M(1) - f(1)) < 1e-5