1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
This commit is contained in:
Justin Lin 2022-05-04 21:15:52 +08:00
parent 1ef1b46a93
commit 0414c440a3

View File

@ -12,12 +12,12 @@ function _combi(n, k) =
n < 4 ? bi_coef[n][k] :
k == 0 ? 1 : (_combi(n, k - 1) * (n - k + 1) / k);
function bezier_curve_coordinate(t, pn, n, i) =
function bezier_curve_component(t, points, n, i) =
let(one_t = 1 - t)
sum([for(j = [0:n]) _combi(n, j) * pn[j][i] * one_t ^ (n - j) * t ^ j]);
sum([for(j = [0:n]) _combi(n, j) * points[j][i] * one_t ^ (n - j) * t ^ j]);
function _bezier_curve(range, t, points, n) =
[for(i = range) bezier_curve_coordinate(t, points, n, i)];
function _bezier_curve_coordinate(range, t, points, n) =
[for(i = range) bezier_curve_component(t, points, n, i)];
function _bezier_curve_impl(t_step, points) =
let(
@ -26,6 +26,6 @@ function _bezier_curve_impl(t_step, points) =
range = [0:len(points[0]) - 1]
)
[
each [for(t = 0; t < t_end; t = t + 1) _bezier_curve(range, t * t_step, points, n)],
_bezier_curve(range, 1, points, n)
each [for(t = 0; t < t_end; t = t + 1) _bezier_curve_coordinate(range, t * t_step, points, n)],
_bezier_curve_coordinate(range, 1, points, n)
];