I have a non-uniform Catmull-Rom spline (so the $t_i$ parameter values are not uniformly distributed). Is there a simple way to calculate the blending functions of the control points? So the spline can be expressed as $f(t)=\sum_{i=0}^nw_i(t)p_i$ (where $p_i$ is the control point itself, and $w_i(t)$ is the blending function)
The spline between the $p_i$ and $p_{i+1}$ is:
$f_i(t) = a_3(t-t_i)^3+a_2(t-t_i)^2+a_1(t-t_i)+a_0$
Where
- $a_0=p_i$
- $a_1=v_1$
- $a_2=\frac{3(p_{i+1}-p_i)}{(t_{i+1}-t_i)^2}-\frac{v_{i+1}+2v_i}{t_{i+1}-t_i}$
- $a_3=\frac{2(p_i-p_{i+1})}{(t_{i+1}-t_i)^3}-\frac{v_{i+1}+v_i}{(t_{i+1}-t_i)^2}$
(And of course, $v_i = \frac{\frac{p_{i+1}-p_i}{t_{i+1}-t_i}+\frac{p_i-p_{i-1}}{t_i-t_{i-1}}}{2}$)
I can express $f_i(t)$ only in terms of $p$-s:
$f_i(t)=\left( 2\frac{(p_i-p_{i+1})}{(t_{i+1}-t_i)^3}+\frac{\frac{\frac{p_{i+2}-p_{i+1}}{t_{i+2}-t_{i+1}}+\frac{p_{i+1}-p_i}{t_{i+1}-t_i}}{2}+\frac{\frac{p_{i+1}-p_i}{t_{i+1}-t_i}+\frac{p_i-p_{i-1}}{t_i-t_{i-1}}}{2}}{(t_{i+1}-t_i)^2} \right )(t-t_i)^3+\left(\frac{3(p_{i+1}-p_i)}{(t_{i+1}-t_i)^2}-\frac{\frac{\frac{p_{i+2}-p_{i+1}}{t_{i+2}-t_{i+1}}+\frac{p_{i+1}-p_i}{t_{i+1}-t_i}}{2}+2\frac{\frac{p_{i+1}-p_i}{t_{i+1}-t_i}+\frac{p_i-p_{i-1}}{t_i-t_{i-1}}}{2}}{t_{i+1}-t_i} \right )(t-t_i)^2+\frac{\frac{p_{i+1}-p_i}{t_{i+1}-t{i}}+\frac{p_i-p_{i-1}}{t_i-t_{i-1}}}{2}(t-t_i)+p_i$
I can do Collect using Mathematica, but it looks like a "brute-force" approach to me, I'm sure there is a much simpler way.
A Catmull-Rom spline can be expressed as a b-spline, of course (every spline can be). So, the first step is to figure out the b-spline representation. The knots of our b-spline are going to be the $2n+6$ values: $$ t_0, t_0, t_0, t_0, t_1, t_1, t_2, t_2, \;\ldots\; t_{n-1}, t_{n-1}, t_n, t_n, t_n, t_n $$ Let $\phi_0, \ldots \phi_{2n+1}$ be the cubic b-spline basis functions constructed from this knot sequence.
Define $2n+2$ points $Q_i$ by $$ \;\;\;\;\;\;Q_0 = P_0 \quad ; \quad Q_1 = P_0 + V_0 \\ Q_2 = P_1 - V_1 \quad ; \quad Q_3 = P_1 + V_1 \\ Q_4 = P_2 - V_2 \quad ; \quad Q_5 = P_2 + V_2 \\ \vdots \\ Q_{2i} = P_i - V_i \quad ; \quad Q_{2i+1} = P_i + V_i \\ \vdots \\ Q_{2n-2} = P_{n-1} - V_{n-1} \quad ; \quad Q_{2n-1} = P_{n-1} + V_{n-1} \\ Q_{2n} = P_{n} - V_{n} \quad ; \quad Q_{2n+1} = P_n $$ where $V_i$ is the derivative vector of the Catmull-Rom spline at point $P_i$. Typically $$ V_i = \frac12\left({\frac{P_{i+1}-P_i}{t_{i+1}-t_i}+\frac{P_i-P_{i-1}}{t_i-t_{i-1}}}\right) $$ Then the Catmull-Rom spline is $$ f(t) = \sum_{i=0}^{2n+1}\phi_i(t)Q_i $$ You can eliminate the $Q_i$ and $V_i$ using the equations above, and you'll end up with something that's in the form that you want. I think it's still going to be a huge mess, but this approach requires less algebra than the one you were using, I think.
The key idea is to use a b-spline or Bezier representation of the spline, rather than the algebraic one you used. In the b-spline or Bezier forms, the relationship with the interpolated points and derivatives is more direct, so there's less algebra.