mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-09-01 03:13:25 +02:00
Merge branch 'master' into pr/483
This commit is contained in:
25
beziers.scad
25
beziers.scad
@@ -413,16 +413,17 @@ function bezier_curvature(curve, u) =
|
||||
// Topics: Bezier Segments
|
||||
// See Also: bezier_curvature(), bezier_tangent(), bezier_derivative(), bezier_points()
|
||||
// Description:
|
||||
// Takes a list of bezier curve control points and generates n points along the bezier path.
|
||||
// Points start at the first control point and are sampled every `1/n`th
|
||||
// of the way along the bezier parameter, ending *before* the final control point by default.
|
||||
// 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`.
|
||||
// Takes a list of bezier control points and generates n points along the bezier curve they define.
|
||||
// Points start at the first control point and are sampled uniformly along the bezier parameter.
|
||||
// The endpoints of the output will be *exactly* equal to the first and last bezier control points
|
||||
// when endpoint is true. If endpoint is false the sampling stops one step before the final point
|
||||
// of the bezier curve, but you still get n, more tightly spaced, points.
|
||||
// The distance between the points will *not* be equidistant.
|
||||
// The degree of the bezier curve is one less than the number of points in `curve`.
|
||||
// Arguments:
|
||||
// curve = The list of endpoints and control points for this bezier segment.
|
||||
// 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
|
||||
// endpoint = if false then exclude the endpoint. Default: True
|
||||
// Example(2D): Quadratic (Degree 2) Bezier.
|
||||
// bez = [[0,0], [30,30], [80,0]];
|
||||
// move_copies(bezier_curve(bez, 8)) sphere(r=1.5, $fn=12);
|
||||
@@ -435,9 +436,11 @@ function bezier_curvature(curve, u) =
|
||||
// bez = [[0,0], [5,15], [40,20], [60,-15], [80,0]];
|
||||
// move_copies(bezier_curve(bez, 8)) sphere(r=1.5, $fn=12);
|
||||
// trace_bezier(bez, N=len(bez)-1);
|
||||
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_curve(curve,n,endpoint=true) =
|
||||
[
|
||||
each bezier_points(curve, rangex(endpoint?n-1:n,0,1)),
|
||||
if (endpoint) last(curve)
|
||||
];
|
||||
|
||||
// Function: bezier_segment_closest_point()
|
||||
// Usage:
|
||||
@@ -769,7 +772,7 @@ function path_to_bezier(path, closed=false, tangents, uniform=false, size, relsi
|
||||
)
|
||||
assert(min(sizevect)>0, "Size and relsize must be greater than zero")
|
||||
[
|
||||
for(i=[0:lastpt-1])
|
||||
for(i=[0:1:lastpt-1])
|
||||
let(
|
||||
first = path[i],
|
||||
second = select(path,i+1),
|
||||
|
Reference in New Issue
Block a user