mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-28 15:59:45 +00:00
fix offset_stroke anchor bug; doc tweaks for Extra Anchors
This commit is contained in:
parent
5d667f105f
commit
33de6a13ea
7 changed files with 87 additions and 66 deletions
|
@ -2957,7 +2957,7 @@ function reorient(
|
|||
axis=UP, override,
|
||||
geom,
|
||||
p=undef
|
||||
) =
|
||||
) =
|
||||
assert(is_undef(anchor) || is_vector(anchor) || is_string(anchor), str("Got: ",anchor))
|
||||
assert(is_undef(spin) || is_vector(spin,3) || is_num(spin), str("Got: ",spin))
|
||||
assert(is_undef(orient) || is_vector(orient,3), str("Got: ",orient))
|
||||
|
@ -3571,7 +3571,7 @@ function _force_anchor_2d(anchor) =
|
|||
/// geom = The geometry description of the shape.
|
||||
function _find_anchor(anchor, geom) =
|
||||
is_string(anchor)? (
|
||||
anchor=="origin"? [anchor, CENTER, UP, 0]
|
||||
anchor=="origin"? [anchor, CENTER, UP, 0] // Ok that this returns 3d anchor in the 2d case?
|
||||
: let(
|
||||
anchors = last(geom),
|
||||
found = search([anchor], anchors, num_returns_per_match=1)[0]
|
||||
|
|
|
@ -314,6 +314,8 @@ function force_region(poly) = is_path(poly) ? [poly] : poly;
|
|||
// spin = Rotate this many degrees after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
// cp = Centerpoint for determining intersection anchors or centering the shape. Determintes the base of the anchor vector. Can be "centroid", "mean", "box" or a 2D point. Default: "centroid"
|
||||
// atype = Set to "hull" or "intersect" to select anchor type. Default: "hull"
|
||||
// Extra Anchors:
|
||||
// "origin" = The native position of the region.
|
||||
// Anchor Types:
|
||||
// "hull" = Anchors to the virtual convex hull of the region.
|
||||
// "intersect" = Anchors to the outer edge of the region.
|
||||
|
|
|
@ -951,6 +951,11 @@ function _path_join(paths,joint,k=0.5,i=0,result=[],relocate=true,closed=false)
|
|||
// spin = Rotate this many degrees after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
// cp = Centerpoint for determining intersection anchors or centering the shape. Determintes the base of the anchor vector. Can be "centroid", "mean", "box" or a 2D point. Default: "centroid"
|
||||
// atype = Set to "hull" or "intersect" to select anchor type. Default: "hull"
|
||||
// Extra Anchors:
|
||||
// "origin" = The native position of the region.
|
||||
// Anchor Types:
|
||||
// "hull" = Anchors to the virtual convex hull of the region.
|
||||
// "intersect" = Anchors to the outer edge of the region.
|
||||
// Example(2D): Basic examples illustrating flat, round, and pointed ends, on a finely sampled arc and a path made from 3 segments.
|
||||
// arc = arc(points=[[1,1],[3,4],[6,3]],n=50);
|
||||
// path = [[0,0],[6,2],[9,7],[8,10]];
|
||||
|
@ -1047,7 +1052,7 @@ function _path_join(paths,joint,k=0.5,i=0,result=[],relocate=true,closed=false)
|
|||
// right(12)
|
||||
// offset_stroke(path, width=1, closed=true);
|
||||
function offset_stroke(path, width=1, rounded=true, start, end, check_valid=true, quality=1, chamfer=false, closed=false,
|
||||
atype="hull", anchor, spin, cp="centroid") =
|
||||
atype="hull", anchor="origin", spin, cp="centroid") =
|
||||
let(path = force_path(path))
|
||||
assert(is_path(path,2),"path is not a 2d path")
|
||||
let(
|
||||
|
@ -1091,7 +1096,7 @@ function offset_stroke(path, width=1, rounded=true, start, end, check_valid=true
|
|||
reverse(slice(right_path,startpath[2],-1-endpath[1])),
|
||||
startpath[0]
|
||||
)
|
||||
)
|
||||
)
|
||||
reorient(anchor=anchor, spin=spin, two_d=true, path=pts, extent=atype=="hull", cp=cp, p=pts);
|
||||
|
||||
function os_pointed(dist,loc=0) =
|
||||
|
@ -2082,6 +2087,11 @@ function _rp_compute_patches(top, bot, rtop, rsides, ktop, ksides, concave) =
|
|||
// orient = Vector to rotate top towards after spin (module only)
|
||||
// atype = Select "hull" or "intersect" anchor types. (module only) Default: "hull"
|
||||
// cp = Centerpoint for determining "intersect" anchors or centering the shape. Determintes the base of the anchor vector. Can be "centroid", "mean", "box" or a 3D point. (module only) Default: "centroid"
|
||||
// Extra Anchors:
|
||||
// "origin" = The native position of the prism.
|
||||
// Anchor Types:
|
||||
// "hull" = Anchors to the virtual convex hull of the prism.
|
||||
// "intersect" = Anchors to the surface of the prism.
|
||||
// Example: Uniformly rounded pentagonal prism
|
||||
// rounded_prism(pentagon(3), height=3,
|
||||
// joint_top=0.5, joint_bot=0.5, joint_sides=0.5);
|
||||
|
|
90
screws.scad
90
screws.scad
|
@ -278,21 +278,21 @@ Torx values: https://www.stanleyengineeredfastening.com/-/media/web/sef/resourc
|
|||
// shank = unthreaded section of shaft (invalid if screw is fully threaded)
|
||||
// threads = threaded section of screw
|
||||
// Extra Anchors:
|
||||
// top = top of screw
|
||||
// bot = bottom of screw
|
||||
// center = center of screw
|
||||
// head_top = top of head (same as top for headless screws)
|
||||
// head_bot = bottom of head (same as top for headless screws)
|
||||
// head_center = center of head (same as top for headless screws)
|
||||
// shaft_top = top of shaft
|
||||
// shaft_bot = bottom of shaft
|
||||
// shaft_center = center of shaft
|
||||
// shank_top = top of shank (invalid if screw is fully threaded)
|
||||
// shank_bot = bottom of shank (invalid if screw is fully threaded)
|
||||
// shank_center = center of shank (invalid if screw is fully threaded)
|
||||
// threads_top = top of threaded portion of screw (invalid if thread_len=0)
|
||||
// threads_bot = bottom of threaded portion of screw (invalid if thread_len=0)
|
||||
// threads_center = center of threaded portion of screw (invalid if thread_len=0)
|
||||
// "top" = top of screw
|
||||
// "bot" = bottom of screw
|
||||
// "center" = center of screw
|
||||
// "head_top" = top of head (same as top for headless screws)
|
||||
// "head_bot" = bottom of head (same as top for headless screws)
|
||||
// "head_center" = center of head (same as top for headless screws)
|
||||
// "shaft_top" = top of shaft
|
||||
// "shaft_bot" = bottom of shaft
|
||||
// "shaft_center" = center of shaft
|
||||
// "shank_top" = top of shank (invalid if screw is fully threaded)
|
||||
// "shank_bot" = bottom of shank (invalid if screw is fully threaded)
|
||||
// "shank_center" = center of shank (invalid if screw is fully threaded)
|
||||
// "threads_top" = top of threaded portion of screw (invalid if thread_len=0)
|
||||
// "threads_bot" = bottom of threaded portion of screw (invalid if thread_len=0)
|
||||
// "threads_center" = center of threaded portion of screw (invalid if thread_len=0)
|
||||
// Example(Med): Selected UTS (English) screws
|
||||
// $fn=32;
|
||||
// xdistribute(spacing=8){
|
||||
|
@ -804,21 +804,21 @@ module screw(spec, head, drive, thread, drive_size,
|
|||
// shank = unthreaded section of shaft (invalid if screw is fully threaded)
|
||||
// threads = threaded section of screw
|
||||
// Extra Anchors:
|
||||
// top = top of screw
|
||||
// bot = bottom of screw
|
||||
// center = center of screw
|
||||
// head_top = top of head (invalid for headless screws)
|
||||
// head_bot = bottom of head (invalid for headless screws)
|
||||
// head_center = center of head (invalid for headless screws)
|
||||
// shaft_top = top of shaft
|
||||
// shaft_bot = bottom of shaft
|
||||
// shaft_center = center of shaft
|
||||
// shank_top = top of shank (invalid if screw is fully threaded)
|
||||
// shank_bot = bottom of shank (invalid if screw is fully threaded)
|
||||
// shank_center = center of shank (invalid if screw is fully threaded)
|
||||
// threads_top = top of threaded portion of screw (invalid if thread_len=0)
|
||||
// threads_bot = bottom of threaded portion of screw (invalid if thread_len=0)
|
||||
// threads_center = center of threaded portion of screw (invalid if thread_len=0)
|
||||
// "top" = top of screw
|
||||
// "bot" = bottom of screw
|
||||
// "center" = center of screw
|
||||
// "head_top" = top of head (invalid for headless screws)
|
||||
// "head_bot" = bottom of head (invalid for headless screws)
|
||||
// "head_center" = center of head (invalid for headless screws)
|
||||
// "shaft_top" = top of shaft
|
||||
// "shaft_bot" = bottom of shaft
|
||||
// "shaft_center" = center of shaft
|
||||
// "shank_top" = top of shank (invalid if screw is fully threaded)
|
||||
// "shank_bot" = bottom of shank (invalid if screw is fully threaded)
|
||||
// "shank_center" = center of shank (invalid if screw is fully threaded)
|
||||
// "threads_top" = top of threaded portion of screw (invalid if thread_len=0)
|
||||
// "threads_bot" = bottom of threaded portion of screw (invalid if thread_len=0)
|
||||
// "threads_center" = center of threaded portion of screw (invalid if thread_len=0)
|
||||
// Example: Counterbored clearance hole
|
||||
// diff()
|
||||
// cuboid(20)
|
||||
|
@ -1038,21 +1038,21 @@ module screw_hole(spec, head, thread, oversize, hole_oversize, head_oversize,
|
|||
// shaft = screw shaft
|
||||
// threads = threaded section of screw
|
||||
// Extra Anchors:
|
||||
// top = top of screw
|
||||
// bot = bottom of screw
|
||||
// center = center of screw
|
||||
// head_top = top of head (invalid for headless screws)
|
||||
// head_bot = bottom of head (invalid for headless screws)
|
||||
// head_center = center of head (invalid for headless screws)
|
||||
// shoulder_top = top of shoulder
|
||||
// shoulder_bot = bottom of shoulder
|
||||
// shoulder_center = center of shoulder
|
||||
// shaft_top = top of shaft
|
||||
// shaft_bot = bottom of shaft
|
||||
// shaft_center = center of shaft
|
||||
// threads_top = top of threaded portion of screw (invalid if thread_len=0)
|
||||
// threads_bot = bottom of threaded portion of screw (invalid if thread_len=0)
|
||||
// threads_center = center of threaded portion of screw (invalid if thread_len=0)
|
||||
// "top" = top of screw
|
||||
// "bot" = bottom of screw
|
||||
// "center" = center of screw
|
||||
// "head_top" = top of head (invalid for headless screws)
|
||||
// "head_bot" = bottom of head (invalid for headless screws)
|
||||
// "head_center" = center of head (invalid for headless screws)
|
||||
// "shoulder_top" = top of shoulder
|
||||
// "shoulder_bot" = bottom of shoulder
|
||||
// "shoulder_center" = center of shoulder
|
||||
// "shaft_top" = top of shaft
|
||||
// "shaft_bot" = bottom of shaft
|
||||
// "shaft_center" = center of shaft
|
||||
// "threads_top" = top of threaded portion of screw (invalid if thread_len=0)
|
||||
// "threads_bot" = bottom of threaded portion of screw (invalid if thread_len=0)
|
||||
// "threads_center" = center of threaded portion of screw (invalid if thread_len=0)
|
||||
// Example: ISO shoulder screw
|
||||
// shoulder_screw("iso",10,length=20);
|
||||
// Example: English shoulder screw
|
||||
|
|
|
@ -864,7 +864,7 @@ module octagon(r, d, or, od, ir, id, side, rounding=0, realign=false, align_tip,
|
|||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
// Extra Anchors:
|
||||
// hypot = Center of angled side, perpendicular to that side.
|
||||
// "hypot" = Center of angled side, perpendicular to that side.
|
||||
// Example(2D):
|
||||
// right_triangle([40,30]);
|
||||
// Example(2D): With `center=true`
|
||||
|
|
|
@ -1121,9 +1121,9 @@ function rect_tube(
|
|||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||
//
|
||||
// Extra Anchors:
|
||||
// hypot = Center of angled wedge face, perpendicular to that face.
|
||||
// hypot_left = Left side of angled wedge face, bisecting the angle between the left side and angled faces.
|
||||
// hypot_right = Right side of angled wedge face, bisecting the angle between the right side and angled faces.
|
||||
// "hypot" = Center of angled wedge face, perpendicular to that face.
|
||||
// "hypot_left" = Left side of angled wedge face, bisecting the angle between the left side and angled faces.
|
||||
// "hypot_right" = Right side of angled wedge face, bisecting the angle between the right side and angled faces.
|
||||
//
|
||||
// Example: Centered
|
||||
// wedge([20, 40, 15], center=true);
|
||||
|
@ -2742,9 +2742,9 @@ function torus(
|
|||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||
//
|
||||
// Extra Anchors:
|
||||
// cap = The center of the top of the cap, oriented with the cap face normal.
|
||||
// cap_fwd = The front edge of the cap.
|
||||
// cap_back = The back edge of the cap.
|
||||
// "cap" = The center of the top of the cap, oriented with the cap face normal.
|
||||
// "cap_fwd" = The front edge of the cap.
|
||||
// "cap_back" = The back edge of the cap.
|
||||
//
|
||||
// Example: Typical Shape
|
||||
// teardrop(r=30, h=10, ang=30);
|
||||
|
@ -2863,8 +2863,8 @@ function teardrop(h, r, ang=45, cap_h, r1, r2, d, d1, d2, cap_h1, cap_h2, chamf
|
|||
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||
//
|
||||
// Extra Anchors:
|
||||
// cap = The center of the top of the cap, oriented with the cap face normal.
|
||||
// tip = The position where an un-capped onion would come to a point, oriented in the direction the point is from the center.
|
||||
// "cap" = The center of the top of the cap, oriented with the cap face normal.
|
||||
// "tip" = The position where an un-capped onion would come to a point, oriented in the direction the point is from the center.
|
||||
//
|
||||
// Example: Typical Shape
|
||||
// onion(r=30, ang=30);
|
||||
|
|
25
skin.scad
25
skin.scad
|
@ -21,7 +21,7 @@
|
|||
// Synopsis: Connect a sequence of arbitrary polygons into a 3D object.
|
||||
// SynTags: VNF, Geom
|
||||
// Topics: Extrusion, Skin
|
||||
// See Also: sweep(), linear_sweep(), rotate_sweep(), spiral_sweep(), path_sweep(), offset_sweep()
|
||||
// See Also: vnf_vertex_array(), sweep(), linear_sweep(), rotate_sweep(), spiral_sweep(), path_sweep(), offset_sweep()
|
||||
// Usage: As module:
|
||||
// skin(profiles, slices, [z=], [refine=], [method=], [sampling=], [caps=], [closed=], [style=], [convexity=], [anchor=],[cp=],[spin=],[orient=],[atype=]) [ATTACHMENTS];
|
||||
// Usage: As function:
|
||||
|
@ -163,6 +163,8 @@
|
|||
// atype = Select "hull" or "intersect" anchor types. Default: "hull"
|
||||
// cp = Centerpoint for determining "intersect" anchors or centering the shape. Determintes the base of the anchor vector. Can be "centroid", "mean", "box" or a 3D point. Default: "centroid"
|
||||
// style = vnf_vertex_array style. Default: "min_edge"
|
||||
// Extra Anchors:
|
||||
// "origin" = The native position of the shape.
|
||||
// Anchor Types:
|
||||
// "hull" = Anchors to the virtual convex hull of the shape.
|
||||
// "intersect" = Anchors to the surface of the shape.
|
||||
|
@ -884,6 +886,8 @@ function linear_sweep(
|
|||
// anchor = Translate so anchor point is at the origin. Default: "origin"
|
||||
// spin = Rotate this many degrees around Z axis after anchor. Default: 0
|
||||
// orient = Vector to rotate top towards after spin (module only)
|
||||
// Extra Anchors:
|
||||
// "origin" = The native position of the shape.
|
||||
// Anchor Types:
|
||||
// "hull" = Anchors to the virtual convex hull of the shape.
|
||||
// "intersect" = Anchors to the surface of the shape.
|
||||
|
@ -1493,10 +1497,11 @@ module spiral_sweep(poly, h, r, turns=1, taper, r1, r2, d, d1, d2, internal=fals
|
|||
// "hull" = Anchors to the virtual convex hull of the shape.
|
||||
// "intersect" = Anchors to the surface of the shape.
|
||||
// Extra Anchors:
|
||||
// start = When `closed==false`, the origin point of the shape, on the starting face of the object
|
||||
// end = When `closed==false`, the origin point of the shape, on the ending face of the object
|
||||
// start-centroid = When `closed==false`, the centroid of the shape, on the starting face of the object
|
||||
// end-centroid = When `closed==false`, the centroid of the shape, on the ending face of the object
|
||||
// "origin" = The native position of the shape
|
||||
// "start" = When `closed==false`, the origin point of the shape, on the starting face of the object
|
||||
// "end" = When `closed==false`, the origin point of the shape, on the ending face of the object
|
||||
// "start-centroid" = When `closed==false`, the centroid of the shape, on the starting face of the object
|
||||
// "end-centroid" = When `closed==false`, the centroid of the shape, on the ending face of the object
|
||||
// Example(NoScales): A simple sweep of a square along a sine wave:
|
||||
// path = [for(theta=[-180:5:180]) [theta/10, 10*sin(theta)]];
|
||||
// sq = square(6,center=true);
|
||||
|
@ -2040,6 +2045,8 @@ function path_sweep(shape, path, method="incremental", normal, closed, twist=0,
|
|||
// orient = Vector to rotate top towards after spin
|
||||
// atype = Select "hull" or "intersect" anchor types. Default: "hull"
|
||||
// cp = Centerpoint for determining "intersect" anchors or centering the shape. Determintes the base of the anchor vector. Can be "centroid", "mean", "box" or a 3D point. Default: "centroid"
|
||||
// Extra Anchors:
|
||||
// "origin" = The native position of the shape.
|
||||
// Anchor Types:
|
||||
// "hull" = Anchors to the virtual convex hull of the shape.
|
||||
// "intersect" = Anchors to the surface of the shape.
|
||||
|
@ -2171,6 +2178,8 @@ function _ofs_face_edge(face,firstlen,second=false) =
|
|||
// anchor = Translate so anchor point is at the origin. Default: "origin"
|
||||
// spin = Rotate this many degrees around Z axis after anchor. Default: 0
|
||||
// orient = Vector to rotate top towards after spin (module only)
|
||||
// Extra Anchors:
|
||||
// "origin" = The native position of the shape.
|
||||
// Anchor Types:
|
||||
// "hull" = Anchors to the virtual convex hull of the shape.
|
||||
// "intersect" = Anchors to the surface of the shape.
|
||||
|
@ -3869,9 +3878,9 @@ function texture(tex, n, border, gap, roughness, inset) =
|
|||
/// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
/// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||
/// Extra Anchors:
|
||||
/// centroid_top = The centroid of the top of the shape, oriented UP.
|
||||
/// centroid = The centroid of the center of the shape, oriented UP.
|
||||
/// centroid_bot = The centroid of the bottom of the shape, oriented DOWN.
|
||||
/// "centroid_top" = The centroid of the top of the shape, oriented UP.
|
||||
/// "centroid" = The centroid of the center of the shape, oriented UP.
|
||||
/// "centroid_bot" = The centroid of the bottom of the shape, oriented DOWN.
|
||||
|
||||
function _get_vnf_tile_edges(texture) =
|
||||
let(
|
||||
|
|
Loading…
Reference in a new issue