1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-31 19:13:33 +02:00

Added bezier_join().

Moved path_length() from sweep.scad to maths.scad.
This commit is contained in:
Chris Palmer
2022-02-23 11:53:02 +00:00
parent 76aa613093
commit 42fccc1afb
6 changed files with 39 additions and 5 deletions

View File

@@ -187,3 +187,7 @@ function cubic_real_roots(a, b, c, d) = //! Returns real roots of cubic equation
) roots == 1 ? [x] :
roots == 2 ? [3 * q /p + inflection, -3 * q / p / 2 + inflection] :
[for(i = [0 : roots - 1]) 2 * sqrt(-p / 3) * cos(acos(3 * q * sqrt(-3 / p) / p / 2) - i * 120) + inflection];
function path_length(path, i = 0, length = 0) = //! Calculated the length along a path
i >= len(path) - 1 ? length
: path_length(path, i + 1, length + norm(path[i + 1] - path[i]));