Add bezier endpoint, tweak _bezcorners to properly produce that

endpoint.  doc tweak for polyhedra.
This commit is contained in:
Adrian Mariano 2021-01-05 23:29:10 -05:00
parent 3712de6c58
commit d097be435b
3 changed files with 13 additions and 9 deletions

View file

@ -238,19 +238,20 @@ function bezier_curvature(curve, u) =
]; ];
// Function: bezier_curve() // Function: bezier_curve()
// Usage: // Usage:
// bezier_curve(curve, n); // bezier_curve(curve, n, [endpoint]);
// Description: // Description:
// Takes a list of bezier curve control points, and a count of path points to generate. The points // Takes a list of bezier curve control points and generates n points along the bezier path.
// returned will be along the curve, starting at the first control point, then about every `1/n`th // Points start at the first control point and are sampled every `1/n`th
// of the way along the curve, ending about `1/n`th of the way *before* the final control point. // of the way along the bezier parameter, ending *before* the final control point by default.
// The distance between the points will *not* be equidistant. The degree of the curve, N, is one // The distance between the points will *not* be equidistant. If you wish to add the
// endpoint you can set `endpoint` to true. The degree of the bezier curve is one
// less than the number of points in `curve`. // less than the number of points in `curve`.
// Arguments: // Arguments:
// curve = The list of endpoints and control points for this bezier segment. // curve = The list of endpoints and control points for this bezier segment.
// n = The number of points to generate along the bezier curve. // n = The number of points to generate along the bezier curve.
// endpoint = if true then add the endpoint (an extra point, giving n+1 points output). Default: False
// Example(2D): Quadratic (Degree 2) Bezier. // Example(2D): Quadratic (Degree 2) Bezier.
// bez = [[0,0], [30,30], [80,0]]; // bez = [[0,0], [30,30], [80,0]];
// move_copies(bezier_curve(bez, 8)) sphere(r=1.5, $fn=12); // move_copies(bezier_curve(bez, 8)) sphere(r=1.5, $fn=12);
@ -263,8 +264,9 @@ function bezier_curvature(curve, u) =
// bez = [[0,0], [5,15], [40,20], [60,-15], [80,0]]; // bez = [[0,0], [5,15], [40,20], [60,-15], [80,0]];
// move_copies(bezier_curve(bez, 8)) sphere(r=1.5, $fn=12); // move_copies(bezier_curve(bez, 8)) sphere(r=1.5, $fn=12);
// trace_bezier(bez, N=len(bez)-1); // trace_bezier(bez, N=len(bez)-1);
function bezier_curve(curve,n) = bezier_points(curve, [0:1/n:(n-0.5)/n]); function bezier_curve(curve,n,endpoint) = [each bezier_points(curve, [0:1/n:(n-0.5)/n]),
if (endpoint) curve[len(curve)-1]
];
// Function: bezier_segment_closest_point() // Function: bezier_segment_closest_point()
// Usage: // Usage:

View file

@ -121,6 +121,7 @@ function _unique_groups(m) = [
// //
// Arguments: // Arguments:
// name = Name of polyhedron to create. // name = Name of polyhedron to create.
// ---
// index = Index to select from polyhedron list. Default: 0. // index = Index to select from polyhedron list. Default: 0.
// type = Type of polyhedron: "platonic", "archimedean", "catalan". // type = Type of polyhedron: "platonic", "archimedean", "catalan".
// faces = Number of faces. // faces = Number of faces.
@ -564,6 +565,7 @@ _stellated_polyhedra_ = [
// //
// Arguments: // Arguments:
// name = Name of polyhedron to create. // name = Name of polyhedron to create.
// ---
// index = Index to select from polyhedron list. Default: 0. // index = Index to select from polyhedron list. Default: 0.
// type = Type of polyhedron: "platonic", "archimedean", "catalan". // type = Type of polyhedron: "platonic", "archimedean", "catalan".
// faces = Number of faces. // faces = Number of faces.

View file

@ -308,7 +308,7 @@ function _bezcorner(points, parm) =
] : _smooth_bez_fill(points,parm), ] : _smooth_bez_fill(points,parm),
N = max(3,$fn>0 ?$fn : ceil(bezier_segment_length(P)/$fs)) N = max(3,$fn>0 ?$fn : ceil(bezier_segment_length(P)/$fs))
) )
bezier_curve(P,N); bezier_curve(P,N,endpoint=true);
function _chamfcorner(points, parm) = function _chamfcorner(points, parm) =
let( let(