By using weights, you can make a rational B-spline, such as a circle:

Choose six points to be interpolated:

Compute distances between control points:

Compute normalized parameters wrt the distances (chord length parametrization):

A cubic B-spline curve with clamped knots will be used:

Set up the square basis matrix to solve:

Solve the linear system to get control points:

Show the interpolating curve with the original data:

Choose 3D points to be interpolated:

Compute distances between control points:

Compute normalized parameters wrt the distances (chord length parametrization):

A cubic B-spline curve with clamped knots will be used:

Set up the square basis matrix to solve:

Solve the linear system to get control points:

Show the interpolating curve with the original data:

Sample a list of points to be approximated with random noise:

Use uniform parametrization:

Define a function to generate clamped knots for a given number of control points and degrees:

Define the basis matrix for least squares:

A cubic B-spline curve with 12 control points will be used for fitting:

Show the data with the curve:

The results with various numbers of control points:

The results with 12 control points and different degrees:

Linear transition from one B-spline curve to another: