mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Fixed bug in path_to_bezier and added example to smooth_path.
This commit is contained in:
parent
51af394c24
commit
a8ed6214be
2 changed files with 4 additions and 2 deletions
|
@ -332,9 +332,9 @@ function bezier_polyline(bezier, splinesteps=16, N=3) = let(
|
|||
// closed = set to true for a closed path. Default: false
|
||||
function path_to_bezier(path, tangent, closed=false) =
|
||||
assert(is_path(path,dim=undef),"Input path is not a valid path")
|
||||
assert(is_undef(tangent) || is_path(tanget,dim=len(path[0])),"Tangent must be a path of the same dimension as the input path")
|
||||
assert(is_undef(tangent) || is_path(tangent,dim=len(path[0])),"Tangent must be a path of the same dimension as the input path")
|
||||
let(
|
||||
tangent = is_def(tangent)? tangent : path_tangents(path, closed=closed),
|
||||
tangent = is_def(tangent)? [for(t=tangent) unit(t)] : path_tangents(path, closed=closed),
|
||||
lastpt = len(path) - (closed?0:1)
|
||||
)
|
||||
[for(i=[0:lastpt-1]) each [path[i], path[i]+tangent[i], select(path,i+1)-select(tangent,i+1)],
|
||||
|
|
|
@ -425,6 +425,8 @@ function _rounding_offsets(edgespec,z_dir=1) =
|
|||
// stroke(smooth_path(square(4)), width=0.1);
|
||||
// Example(2D): Closing the path changes the end tangents
|
||||
// polygon(smooth_path(square(4), closed=true));
|
||||
// Example(2D): You can specify your own tangent values to alter the shape of the curve
|
||||
// polygon(smooth_path(square(4),tangent=[[-2,-1], [-2,1], [1,2], [2,-1]],closed=true));
|
||||
// Example(FlatSpin): Works on 3d paths as well
|
||||
// path = [[0,0,0],[3,3,2],[6,0,1],[9,9,0]];
|
||||
// trace_polyline(smooth_path(path),size=.3);
|
||||
|
|
Loading…
Reference in a new issue