on-internet
← Community

Is there a way to vectorize the De Casteljau's algorithm in NumPy?

Stack Overflow ·

De Casteljau's algorithm is used to interpolate a Bézier curve and consists a recursive (or iterative) procedure to reduce the number of linear segments until only one is left and the interpolation gives a single point. Here in the iterative form: import numpy as np import matplotlib.pyplot as plt def de_casteljau(cp, t): interpolated = cp.copy() for i in range(len(cp)-1): p_from = interpolated[:-1] p_to = interpolated[1:] interpolated = t * p_from + (1-t) * p_to return interpolated[0,:] cp = np.array([[268, 113], [293, 226], [284, 277], [206, 146]]) t = np.linspace(0, 1, num=50, endpoint=True

Comments

Sign in or sign up to comment and upvote.

No comments yet.