Conversion from cubic catmull-rom spline to cubic b-spline

I have a bunch of points that are the control vertices of a cubic catmull-rom spline. I would like to convert these to the control vertices of a cubic bspline.

I believe I can do this using this following relation: $$\boldsymbol{t} * \boldsymbol{B}_{\text{catmull}} * \boldsymbol{V}_{\text{catmull}} = \boldsymbol{t} * \boldsymbol{B}_{\text{bspline}} * \boldsymbol{V}_{\text{bspline}}$$

where $$\boldsymbol{B}$$ is the basis matrix and $$\boldsymbol{V}$$ is a vector of the control vertices. To get the control vertices of the bspline, the formula just becomes:

$$\boldsymbol{V}_{\text{bspline}} = \boldsymbol{B}^{-1}_{\text{bspline}} * \boldsymbol{B}_{\text{catmull}} * \boldsymbol{V}_{\text{catmull}}$$

My question is once I process say 4 control vertices of the catmull rom spline, to get 4 vertices of the bspline, how do I process other vertices (i.e the order). If a catmull-rom spline has n-vertices with cubic segments, then we have at the most $$n-3$$ segments. So if we have say 5 vertices, $$v_0, v_1, v_2, v_3$$ gives us 4 vertices for bspline. How would I go about computing the other curve segment in the bspline?

• Being pedantic, I guess you meant "uniform cubic b-spline". – Simon F Nov 15 '18 at 8:58
• Yes. I forgot to mention that. – sriravic Nov 15 '18 at 15:17
• Just to confirm, are you asking, given a set of N CatRom cps, {CR0, CR1, CR2, CR3 ... CRn-1} forming a piecewise curve, what is the equivalent N points, {B0,B1,B2...Bn-1} for a matching piecewise uniform cubic bspline? – Simon F Nov 16 '18 at 10:24
• Exactly. That is what I'm looking for. I think conversion to cubic bezier's are easy. But I would like to know if this is even possible/doable with bsplines. – sriravic Nov 16 '18 at 15:17
• I think it's a little trickier but I think there may be an approach. Still trying to work out the details. – Simon F Nov 17 '18 at 16:23

Quoting the comments above for context:

Just to confirm, are you asking, given a set of $$N$$ CatRom control points, $$\{CR_0, CR_1, CR_2, CR_3 ... CR_{n-1}\}$$ forming a piecewise curve, what is the equivalent $$N$$ points, $$\{B_0,B_1,B_2...B_{n-1}\}$$ for a matching piecewise uniform cubic bspline?

Exactly. That is what I'm looking for. I think conversion to cubic bezier's are easy. But I would like to know if this is even possible/doable with bsplines

I think it's a bit complicated: Using the approach you described above, i.e. $$V_{targetformat} = M_{targetformat}^{-1} . M_{sourceformat}.V_{sourceformat}$$ you can easily go from a sequence of $$n$$ control points of Catmull-Rom to $$(n-3)$$ sets of 4 Uniform BSpline control points, i.e. a total of $$4n-12$$ control points , but I can't see that this will allow you to stitch them together to obtain just $$n$$ points...

Assuming I've got the correct matrices for the 'typical' Catmull-Rom, $$M_{CR}=\frac{1}{2}\begin{bmatrix} -1 & 3 & -3 & 1\\ 2 & -5 & 4 & -1 \\ -1 & 0 & 1 & 0 \\ 0 & 2 & 0 & 0\\ \end{bmatrix}$$ and uniform B-Spline: $$M_{UB}=\frac{1}{6}\begin{bmatrix} -1 & 3 & -3 & 1\\ 3 & -6 & 3 & 0 \\ -3 & 0 & 3 & 0 \\ 1 & 4 & 1 & 0\\ \end{bmatrix}$$ then $$M^{-1}_{UB}.M_{CR}$$ should be
[UPDATE: Fixed errors in coefficents] $$\frac{1}{6}\begin{bmatrix} 7 & -4 & 5 & -2\\ -2 & 11 & -4 & 1 \\ 1 & -4 & 11 & -2 \\ -4 & 13 & -26 & 11\\ \end{bmatrix}$$

It seems to me that, in any batch of four points, every output vertex thus depends on every input vertex, so it seems the neighbouring points can't be shared.

Having said this, I think perhaps there might be a way of getting an approximate solution (but I've not tried rendering it myself to check it so take with a grain of salt)

We know that a Catmull-Rom spline defined by $$(CR_A, CR_B, CR_C, CR_D)$$, passes through $$CR_B$$ and $$CR_C$$ at t=0 and t=1 respectively.

Similarly, using $$\begin{bmatrix}t^3 & t^2 & t & 1\end{bmatrix}.M_{UB}$$, we should see that at t=0 and t=1, a B-spline passes through $$\frac{B_A + 4 B_B + B_C}{6}$$ and $$\frac{B_B + 4 B_C + B_D}{6}$$.

First consider trying to go from BSpline to CR. If we had a 'loop' formed by N control points one would map from BSpline to CR with... $$\begin{bmatrix}CR_0\\CR_1\\ ...\\CR_{n-1} \end{bmatrix} = M_{NxBtoCR}.\begin{bmatrix}B_0\\B_1\\ ...\\B_{n-1} \end{bmatrix}$$ where $$M_{NxBtoCR}= \frac{1}{6}.\begin{bmatrix} 4 & 1 & 0 & 0 & ... & 0 & 1\\ 1 & 4 & 1 & 0 & ... & 0 & 0\\ 0 & 1 & 4 & 1 & ... & 0 & 0\\ : & : & & & ... & : & :\\ 1 & 0 & 0 & 0 & ... & 1 & 4\\ \end{bmatrix}$$ If we invert that matrix to get $$M_{NxBtoCR}^{-1}$$, one should then be able to map the other way.

Using a maths package such as Maple, one finds that each row of $$M_{NxBtoCR}^{-1}$$ consists of the same set of values, all non-zero, which are progressively offset in each row. If we ignore the smaller terms, it suggests that $$B_i \approx 1.732 CR_i -0.464 (CR_{i-1}+CR_{i+1}) + 0.1243 (CR_{i-2}+CR_{i+2}) - 0.033(CR_{i-3}+CR_{i+3})$$

There's probably some nice algebraic expression for this but I hope this might "do the trick".

Update Those weights don't quite sum to 1.0 - you'll need to normalise them slightly.

Obviously, this has assumed the curve is a loop. It's probably possible to adjust the weights for the end points but I'll leave that as an exercise for the reader.

• Correcting M−1UB.MCR I've tested the matrices using renderings, the top right and bottom left values of the matrix are wrong, they should be negative. – Edwin Fan yesterday
• My apologies.. I must have mistyped copying the values when I used Maple to do the calculations. The error is more than just signs! Will fix ASAP – Simon F 14 hours ago