It is programmed as (Bint.java)
public void findCPoints(){ Bi[1] = -.25; Ax[1] = (Px[2] - Px[0] - dx[0])/4; Ay[1] = (Py[2] - Py[0] - dy[0])/4; for (int i = 2; i < N-1; i++){ Bi[i] = -1/(4 + Bi[i-1]); Ax[i] = -(Px[i+1] - Px[i-1] - Ax[i-1])*Bi[i]; Ay[i] = -(Py[i+1] - Py[i-1] - Ay[i-1])*Bi[i]; } for (int i = N-2; i > 0; i--){ dx[i] = Ax[i] + dx[i+1]*Bi[i]; dy[i] = Ay[i] + dy[i+1]*Bi[i]; } }You can compare here Interpolating B-spline and Cardinal curve.
Handling the terminal tangentsIf you don't like to worry about terminal tangents of interpolating curve, you can direct them to the nearest point as for Cardinal curve, i.e. ("1/3 rule" is used)d0 = (P1 - P0)/3, dn = (Pn - Pn-1)/3 . Interpolating applet without terminal tangents. Drag the mouse to move a control point. Click mouse + "Shift"("Ctrl") to add (remove) a point. |
Don't you know the name of the interpolating B-spline?