mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-31 21:32:01 +02:00
Added force_list, path_to_bezier, smooth_path, associate_vertices,
improved skin and sweep error handling. Allow path_sweep to take a 2d path.
This commit is contained in:
27
beziers.scad
27
beziers.scad
@@ -9,8 +9,8 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
include <BOSL2/vnf.scad>
|
||||
|
||||
include <vnf.scad>
|
||||
include <skin.scad>
|
||||
|
||||
// Section: Terminology
|
||||
// **Polyline**: A series of points joined by straight line segements.
|
||||
@@ -318,6 +318,29 @@ function bezier_polyline(bezier, splinesteps=16, N=3) = let(
|
||||
);
|
||||
|
||||
|
||||
// Function: path_to_bezier()
|
||||
// Usage:
|
||||
// path_to_bezier(path,[tangent],[closed]);
|
||||
// Description:
|
||||
// Given an input path and optional path of tangent vectors, computes a cubic (degree 3) bezier path that passes
|
||||
// through every point on the input path and matches the tangent vectors. If you do not supply
|
||||
// the tangent it will be computed using path_tangents. If the path is closed specify this
|
||||
// by setting closed=true.
|
||||
// Arguments:
|
||||
// path = path of points to define the bezier
|
||||
// tangents = optional list of tangent vectors at every point
|
||||
// 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")
|
||||
let(
|
||||
tangent = is_def(tangent)? tangent : 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)],
|
||||
select(path,lastpt)];
|
||||
|
||||
|
||||
|
||||
// Function: fillet_path()
|
||||
// Usage:
|
||||
|
Reference in New Issue
Block a user