Created
November 28, 2019 11:02
-
-
Save jbush001/6e08a8b64e154f37cc31d3c0df0ae7a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cubic_bezier(control_points, steps) = [ | |
for (t = [0 : 1 / steps : 1]) [ | |
for (i = [0:1]) | |
pow(1 - t, 3) * control_points[0][i] + 3 * pow(1 - t, 2) * t * control_points[1][i] | |
+ 3 * (1 - t) * pow(t, 2) * control_points[2][i] + pow(t, 3) * control_points[3][i] | |
] | |
]; | |
function bezier_path(points, steps) = [ | |
for (a = [for (i = [0 : 3 : len(points) - 3]) | |
cubic_bezier([for (j = [0:3]) points[i + j]], steps)]) for (b = a) b | |
]; | |
module extrude_path(points, steps, height) { | |
linear_extrude(height=height) polygon(bezier_path(points, steps)); | |
} | |
// Test | |
extrude_path([[-10, -10], [-5, -25], [15, -15], [10, -10], [15, -5], [15, 5], [10, 10], [5, 20], [-5, 20], [-10, 10]], 32, 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment