blob: ec805147e4db4a7f6395da307b37aca7a0e08176 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
function bezier(points, t) =
len(points) == 1 ? points[0] :
bezier([for (i = [0:len(points)-2])
(1 - t) * points[i] + t * points[i + 1]], t);
function bezier_curve(points, $fn=$fn) =
[for (i = [0:$fn]) bezier(points, i / $fn)];
points = [[0, 0], [10, 0], [1, 5], [20, 1], [0, 10]];
$fn = 100;
curve = bezier_curve(points);
polygon(curve);
|