mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-08-31 19:13:33 +02:00
Single backtick now used for all code quotes.
This commit is contained in:
@@ -22,14 +22,14 @@
|
||||
//
|
||||
include <../global_defs.scad>
|
||||
|
||||
function bezier(t, v) = //! Returns a point at distance ```t``` [0 - 1] along the curve with control points ```v```
|
||||
function bezier(t, v) = //! Returns a point at distance `t` [0 - 1] along the curve with control points `v`
|
||||
(len(v) > 2) ? bezier(t, [for (i = [0 : len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)])
|
||||
: v[0] * (1 - t) + v[1] * (t);
|
||||
|
||||
function bezier_path(v, steps = 100) = //! Returns a Bezier path from control points ```v``` with ```steps``` segments
|
||||
function bezier_path(v, steps = 100) = //! Returns a Bezier path from control points `v` with `steps` segments
|
||||
[for(i = [0 : steps], t = i / steps) bezier(t, v)];
|
||||
|
||||
function bezier_length(v, delta = 0.01, t = 0, length = 0) = //! Calculate the length of a Bezier curve from control points ```v```
|
||||
function bezier_length(v, delta = 0.01, t = 0, length = 0) = //! Calculate the length of a Bezier curve from control points `v`
|
||||
t > 1 ? length
|
||||
: bezier_length(v, delta, t + delta, length + norm(bezier(t, v) - bezier(t + delta, v)));
|
||||
|
||||
@@ -37,7 +37,7 @@ function adjust_bezier(v, r) =
|
||||
let(extension = (v[1] - v[0]) * (r - 1))
|
||||
[v[0], v[1] + extension, v[2] + extension, v[3]];
|
||||
|
||||
function adjust_bezier_length(v, l, eps = 0.001, r1 = 1.0, r2 = 1.5, l1, l2) = //! Adjust Bezier control points ```v``` to get the required curve length ```l```
|
||||
function adjust_bezier_length(v, l, eps = 0.001, r1 = 1.0, r2 = 1.5, l1, l2) = //! Adjust Bezier control points `v` to get the required curve length `l`
|
||||
let(l1 = l1 != undef ? l1 : bezier_length(adjust_bezier(v, r1)),
|
||||
l2 = l2 != undef ? l2 : bezier_length(adjust_bezier(v, r2))
|
||||
) abs(l1 - l) < eps ? adjust_bezier(v, r1)
|
||||
@@ -45,10 +45,10 @@ function adjust_bezier_length(v, l, eps = 0.001, r1 = 1.0, r2 = 1.5, l1, l2) = /
|
||||
abs(r - r1) < abs(r - r2) ? adjust_bezier_length(v, l, eps, r, r1, undef, l1)
|
||||
: adjust_bezier_length(v, l, eps, r, r2, undef, l2);
|
||||
|
||||
function bezier_min_z(v, steps = 100, z = inf, i = 0) = //! Calculate the minimum z coordinate of a Bezier curve from control points ```v```
|
||||
function bezier_min_z(v, steps = 100, z = inf, i = 0) = //! Calculate the minimum z coordinate of a Bezier curve from control points `v`
|
||||
i <= steps ? bezier_min_z(v, steps, min(z, bezier(i / steps, v).z), i + 1) : z;
|
||||
|
||||
function adjust_bezier_z(v, z, eps = 0.001, r1 = 1, r2 = 1.5, z1, z2) = //! Adjust Bezier control points ```v``` to get the required minimum ```z```
|
||||
function adjust_bezier_z(v, z, eps = 0.001, r1 = 1, r2 = 1.5, z1, z2) = //! Adjust Bezier control points `v` to get the required minimum `z`
|
||||
let(z1 = z1 != undef ? z1 : bezier_min_z(adjust_bezier(v, r1)),
|
||||
z2 = z2 != undef ? z2 : bezier_min_z(adjust_bezier(v, r2))
|
||||
) abs(z1 - z) < eps ? adjust_bezier(v, r1)
|
||||
|
Reference in New Issue
Block a user