misc doc fixes and organization

beziers reorg
arc bug fix for endpoint=false and N=undef
This commit is contained in:
Adrian Mariano 2022-01-07 14:23:01 -05:00
parent 1df2d49e3c
commit d8aa4ced71
10 changed files with 777 additions and 868 deletions

View file

@ -1274,25 +1274,6 @@ module attachable(
}
// Function: named_anchor()
// Usage:
// a = named_anchor(name, pos, [orient], [spin]);
// Topics: Attachments
// See Also: reorient(), attachable()
// Description:
// Creates an anchor data structure. For a more step-by-step explanation of attachments,
// see the [[Attachments Tutorial|Tutorial-Attachments]].
// Arguments:
// name = The string name of the anchor. Lowercase. Words separated by single dashes. No spaces.
// pos = The [X,Y,Z] position of the anchor.
// orient = A vector pointing in the direction parts should project from the anchor position.
// spin = If needed, the angle to rotate the part around the direction vector.
function named_anchor(name, pos=[0,0,0], orient=UP, spin=0) = [name, pos, orient, spin];
// Function: reorient()
//
// Usage: Square/Trapezoid Geometry
@ -1418,6 +1399,24 @@ function reorient(
) _attach_transform(anchor,spin,orient,geom,p);
// Function: named_anchor()
// Usage:
// a = named_anchor(name, pos, [orient], [spin]);
// Topics: Attachments
// See Also: reorient(), attachable()
// Description:
// Creates an anchor data structure. For a more step-by-step explanation of attachments,
// see the [[Attachments Tutorial|Tutorial-Attachments]].
// Arguments:
// name = The string name of the anchor. Lowercase. Words separated by single dashes. No spaces.
// pos = The [X,Y,Z] position of the anchor.
// orient = A vector pointing in the direction parts should project from the anchor position.
// spin = If needed, the angle to rotate the part around the direction vector.
function named_anchor(name, pos=[0,0,0], orient=UP, spin=0) = [name, pos, orient, spin];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//

File diff suppressed because it is too large Load diff

View file

@ -172,6 +172,10 @@ CENTER = [ 0, 0, 0]; // Centered zero vector.
CTR = CENTER;
// Section: Line specifiers
// Used by functions in geometry.scad for specifying whether two points
// are treated as an unbounded line, a ray with one endpoint, or a segment
// with two endpoints.
// Constant: SEGMENT
// Topics: Constants, Lines

View file

@ -650,7 +650,7 @@ module dashed_stroke(path, dashpat=[3,3], width=1, closed=false) {
function arc(N, r, angle, d, cp, points, width, thickness, start, wedge=false, long=false, cw=false, ccw=false, endpoint=true) =
assert(is_bool(endpoint))
!endpoint ? assert(!wedge, "endpoint cannot be false if wedge is true")
list_head(arc(N+1,r,angle,d,cp,points,width,thickness,start,wedge,long,cw,ccw,true)) :
list_head(arc(u_add(N,1),r,angle,d,cp,points,width,thickness,start,wedge,long,cw,ccw,true)) :
assert(is_undef(N) || (is_integer(N) && N>=2), "Number of points must be an integer 2 or larger")
// First try for 2D arc specified by width and thickness
is_def(width) && is_def(thickness)? (

View file

@ -996,8 +996,8 @@ module rabbit_clip(type, length, width, snap, thickness, depth, compression=0.1
? concat(pin_smooth, reverse(pin_smooth))
: let(side_smooth=select(pin_smooth, 0, 2))
concat(side_smooth, [socket_smooth], reverse(side_smooth));
bez = path_to_bezier(path,relsize=smoothing,tangents=tangent);
rounded = bezier_path(bez,splinesteps=splinesteps);
bez = path_to_bezpath(path,relsize=smoothing,tangents=tangent);
rounded = bezpath_curve(bez,splinesteps=splinesteps);
bounds = pointlist_bounds(rounded);
extrapt = is_pin ? [] : [rounded[0] - [0,extra]];
finalpath = is_pin ? rounded

View file

@ -387,6 +387,7 @@ function repeat(val, n, i=0) =
// s = The starting value of the list of numbers.
// step = The amount to increment successive numbers in the list.
// reverse = Reverse the list. Default: false.
// See Also: idx()
// Example:
// nl1 = count(5); // Returns: [0,1,2,3,4]
// nl2 = count(5,3); // Returns: [3,4,5,6,7]
@ -851,9 +852,10 @@ function idx(list, s=0, e=-1, step=1) =
// Topics: List Handling, Iteration
// See Also: idx(), triplet(), combinations(), permutations()
// Description:
// Takes a list, and returns a list of adjacent pairs from it, optionally wrapping back to the front.
// Returns a list of all of the pairs of adjacent items from a list, optionally wrapping back to the front. The pairs overlap, and
// are returned in order starting with the first two entries in the list. If the list has less than two elements, the empty list is returned.
// Arguments:
// list = The list to iterate.
// list = The list to use for making pairs
// wrap = If true, wrap back to the start from the end. ie: return the last and first items as the last pair. Default: false
// Example(2D): Does NOT wrap from end to start,
// for (p = pair(circle(d=40, $fn=12)))
@ -883,7 +885,7 @@ function pair(list, wrap=false) =
// Topics: List Handling, Iteration
// See Also: idx(), pair(), combinations(), permutations()
// Description:
// Takes a list, and returns a list of adjacent triplets from it, optionally wrapping back to the front.
// Returns a list of all adjacent triplets from a list, optionally wrapping back to the front.
// If you set `wrap` to true then the first triplet is the one centered on the first list element, so it includes
// the last element and the first two elements. If the list has fewer than three elements then the empty list is returned.
// Arguments:

View file

@ -176,7 +176,7 @@ module chain_hull()
// trapezoid(w1=10, w2=5, h=10, anchor=BACK);
// Example:
// include <BOSL2/beziers.scad>
// path = bezier_path([
// path = bezpath_curve([
// [-50,0], [-25,50], [0,0], [50,0]
// ]);
// path_extrude2d(path, caps=false)

View file

@ -10,7 +10,7 @@
// Includes:
// include <BOSL2/std.scad>
// FileGroup: Advanced Modeling
// FileSummary: Work with arbitrary 2D or 3D paths.
// FileSummary: Operations on paths: length, resampling, tangents, splitting into subpaths
// FileFootnotes: STD=Included in std.scad
//////////////////////////////////////////////////////////////////////

View file

@ -345,7 +345,7 @@ function _bezcorner(points, parm) =
points[1]+k*d*next,
points[1]+d*next
] : _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_length(P)/$fs))
)
bezier_curve(P,N+1,endpoint=true);
@ -450,7 +450,7 @@ function _rounding_offsets(edgespec,z_dir=1) =
// in which case the size parameter specifies the sum of the deviations of the two peaks of the curve. In 3-space
// the bezier curve may have three extrema: two maxima and one minimum. In this case the size specifies
// the sum of the maxima minus the minimum. At a given segment there is a maximum size: if your size
// value is too large it will be rounded down. See also path_to_bezier().
// value is too large it will be rounded down. See also path_to_bezpath().
// Arguments:
// path = path to smooth
// tangents = tangents constraining curve direction at each point. Default: computed automatically
@ -503,9 +503,9 @@ module smooth_path(path, tangents, size, relsize, splinesteps=10, uniform=false,
function smooth_path(path, tangents, size, relsize, splinesteps=10, uniform=false, closed) =
is_1region(path) ? smooth_path(path[0], tangents, size, relsize, splinesteps, uniform, default(closed,true)) :
let (
bez = path_to_bezier(path, tangents=tangents, size=size, relsize=relsize, uniform=uniform, closed=default(closed,false))
bez = path_to_bezpath(path, tangents=tangents, size=size, relsize=relsize, uniform=uniform, closed=default(closed,false))
)
bezier_path(bez,splinesteps=splinesteps);
bezpath_curve(bez,splinesteps=splinesteps);
@ -665,7 +665,7 @@ function _path_join(paths,joint,k=0.5,i=0,result=[],relocate=true,closed=false)
loop?"closing the path":str("adding path ",i+1)))
let(
bezpts = _smooth_bez_fill([firstcut[0], corner, nextcut[0]],k[i]),
N = max(3,$fn>0 ?$fn : ceil(bezier_segment_length(bezpts)/$fs)),
N = max(3,$fn>0 ?$fn : ceil(bezier_length(bezpts)/$fs)),
bezpath = approx(firstcut[0],corner) && approx(corner,nextcut[0])
? []
: bezier_curve(bezpts,N),

View file

@ -1281,8 +1281,7 @@ function skew(p=_NO_ARG, sxy=0, sxz=0, syx=0, syz=0, szx=0, szy=0) =
p==_NO_ARG? m : apply(m, p);
// Section: Applying transformation matrices to
// Section: Applying transformation matrices to data
/// Internal Function: is_2d_transform()
/// Usage: