All problems
Bezier Curve Point
Problem
Evaluate a Bezier curve at parameter t in [0, 1] with de Casteljau's algorithm.
points is a list of 2D control points; repeatedly replace each consecutive pair by its linear interpolation at t until one point remains, and return that point as [x, y].
Hint
de Casteljau builds the point from repeated linear interpolations, which is numerically stable.
Test cases
case 1
in: [[[0,0],[1,2],[2,0]],0.5]
expected: [1,1]
case 2
in: [[[0,0],[1,2],[2,0]],0]
expected: [0,0]
case 3
in: [[[0,0],[1,2],[2,0]],1]
expected: [2,0]
case 4
in: [[[0,0],[0,1],[1,1],[1,0]],0.5]
expected: [0.5,0.75]
case 5
in: [[[1,2],[3,6]],0.25]
expected: [1.5,3]
Starter codePython
def bezier_point(points, t):
# Your code here
pass5 test cases · run your code against them in the editor