import numpy as np from scipy.interpolate import BSpline # create control points x = [1, 3, 5, 7, 9] y = [0, 2, 1, 2, 0] # define degree of the curve degree = 3 # create the B-spline curve curve = BSpline(x, y, degree) # evaluate the curve at some points t = np.linspace(1, 9, 100) y_vals = curve(t) # plot the curve import matplotlib.pyplot as plt plt.plot(t, y_vals) plt.show()
# modify control points x[2] = 4 y[3] = 3 # update the curve with the new control points curve = BSpline(x, y, degree) # evaluate the curve at the same points as before y_vals = curve(t) # plot the updated curve plt.plot(t, y_vals) plt.show()This example modifies the third control point of the previously created curve and updates it. The curve is then evaluated at the same points as before and plotted.