I use B-spline curve fitting to obtain one smooth curve. If I obtain two smooth B-spline , how can I connect then smoothly. For example, I have 59 points((x0,y0,z0),...,(x58, y58, z58)) and I have two fitted B spline. One B-spline is for the first 30 points, another is for the next 30 points and the two point set share one common point((x29,y29,z29)). The point (x29,y29,z29) will be modified twice due to curve fitting and will have two new positions. If I just connect the two new positions, the final curve will not be smooth at the point (x29,y29,z29). Currently I perform curve fitting for all data together but that will modify the smooth curve for the first 30 points entirely. I hope to only modify the connecting part of the first smooth curve. I know I need to impose derivatives need to be equal at the joint. I don't know how to do that.
1 Answers
It looks like you are doing LS fitting with B-spline curves or something similar and in general the B-spline obtained this way will not pass any of the data points. This is why the two B-splines do not meet at the common point.
To solve this problem, you can enhance your LS fitting function to take constraints as part of the input. In your cases, these constraints are linear and therefore your problem will still be linear. Once this step is done, you can pre-calculate the slope at the common point and constrain both B-spline fitting to the common point and common slope. This way the two B-splines obtained will at least be G1 continuous at the common point.
Having said this, to implement a constrained LS fitting is not a trivial task, which cannot be easily elaborated here either. So, you will have to do some "googling" yourself. An alternative solution will be to "tweak" your two B-splines to make them connected in a G1 manner. But doing so will certainly increase the fitting error as the sense of least squared error is destroyed. By "tweaking", I meant to change the B-spline's control points locally. In the following I will give more details.
Supposed you have two B-splines C1(t) and C2(t) and the last two control points of C1(t) are P(n-2) and P(n-1) and the first two control points of C2(t) are Q(0) and Q(1). P(n-1) and Q(0) are supposed to be close to the common point (x29, y29, z29) of the two data set. Tweaking the B-spline curves simply means changing the location of P(n-2), P(n-1), Q(0) and Q(1) so that these two B-spline curves will meet in a G1 manner. To do this,
1) we first make them G0 by moving both P(n-1) and Q(0) to the same location, which can be (x29, y29, z29) or simply the midpoint between P(n-1) and Q(0). Let's denote this new location as R.
2) Now, check if P(n-2), R and Q(1) are collinear. If they happens to be collinear, then the two B-spline curves will be G1 as well and you are done. If they are not collinear, find the best approximating line passing thru R from P(n-2) and Q(1), then project P(n-2) and Q(1) onto this line and use the projected points as the new location of P(n-2) and Q(1).
After these two steps, these two B-spline curves should be connected in G1 manner. But the error to the original data points around the common joint will become bigger.

- 3,473
- 1
- 13
- 19
-
Your reply is very helpful to me. Can you clarify the idea about tweaking two B-splines? I am considering using this method because least square is not important. It is better to give some links or papers. – Jogging Song Oct 29 '14 at 07:17
-
Currently I am reading the paper:http://www1.eafit.edu.co/cadcamcae/documents/BiCurve_MultiPatch_AnalesIngGrafica_2008.pdf – Jogging Song Oct 29 '14 at 09:01
-
@OP: I added more content to the answer about how to tweak the B-splines to achieve G1 continuity. – fang Oct 29 '14 at 20:23
-
If I need to modify two control points P(n-2) and P(n-1), do I need to recalculate whole points of B-spline C1(t)? – Jogging Song Nov 05 '14 at 09:14
-
No. You don't need to. – fang Nov 05 '14 at 17:01
-
If I have one B-spline curve, I hope to edit the curve, draw one additional curve around the original curve, and join the two curve together. Is there any open source geometrical modeling software that have such functionality? – Jogging Song Nov 12 '14 at 14:37
-
From what I learned, is the problem B-spline for interpolation with constraints? – Jogging Song Nov 12 '14 at 15:12
-
If you just want to join two B-spline curves together, you do not need to resort to B-spline interpolation with constraints, which is overkilled for this problem. This functionality is quite common in commercial geometric modeling software. But I don't know where to find open source codes. – fang Nov 12 '14 at 20:15