Compare commits

...

13 commits

Author SHA1 Message Date
adrianVmariano
e555b77928
Merge 5c3692d109 into 53af9121e7 2024-08-30 23:43:01 +00:00
Adrian Mariano
5c3692d109 fix inside attachment spin bug 2024-08-30 19:42:41 -04:00
Revar Desmera
53af9121e7
Merge pull request #1464 from adrianVmariano/master
doc fix & screws fix
2024-08-11 22:48:27 -07:00
Revar Desmera
736fad321b
Merge pull request #1459 from adrianVmariano/master 2024-07-27 14:01:30 -07:00
Revar Desmera
cc08eb3323
Merge pull request #1458 from adrianVmariano/master
Fix new examples
2024-07-27 02:21:31 -07:00
Revar Desmera
78ea8e4770
Merge pull request #1457 from adrianVmariano/master
vnf_sheet & bezier_sheet
2024-07-25 23:01:31 -07:00
Revar Desmera
8383d360cc
Merge pull request #1454 from adrianVmariano/master
various fixes
2024-07-19 21:35:00 -07:00
Revar Desmera
9145c0961f
Merge pull request #1450 from BelfrySCAD/revarbat_dev
Remove redundant collinear points from bezpath_curve() output.
2024-07-07 00:34:15 -07:00
Revar Desmera
ebb98b47d2 Remove redundant collinear points from bezpath_curve() output. 2024-07-07 00:11:23 -07:00
Revar Desmera
8ea8ebf341
Merge pull request #1447 from adrianVmariano/master
su/product optimization
2024-06-29 15:41:11 -07:00
Revar Desmera
17e307fdb4
Merge pull request #1446 from adrianVmariano/master
projection doc fix
2024-06-22 20:58:13 -07:00
Revar Desmera
67f0004773
Merge pull request #1445 from adrianVmariano/master
add projection()
2024-06-22 18:10:12 -07:00
Revar Desmera
76d09271c1
Merge pull request #1441 from adrianVmariano/master
spiral sweep bugfix
2024-06-12 22:57:08 -07:00
2 changed files with 17 additions and 14 deletions

View file

@ -921,11 +921,13 @@ module attach(parent, child, overlap, align, spin=0, norot, inset=0, shiftout=0,
anchor = is_string(anchors[anch_ind])? anchors[anch_ind] anchor = is_string(anchors[anch_ind])? anchors[anch_ind]
: two_d?_force_anchor_2d(anchors[anch_ind]) : two_d?_force_anchor_2d(anchors[anch_ind])
: point3d(anchors[anch_ind]); : point3d(anchors[anch_ind]);
$anchor=anchor;
anchor_data = _find_anchor(anchor, $parent_geom); anchor_data = _find_anchor(anchor, $parent_geom);
anchor_pos = anchor_data[1]; anchor_pos = anchor_data[1];
anchor_dir = factor*anchor_data[2]; anchor_dir = factor*anchor_data[2];
anchor_spin = !inside || anchor==TOP || anchor==BOT ? anchor_data[3] : 180+anchor_data[3]; anchor_spin = !inside || anchor==TOP || anchor==BOT ? anchor_data[3]
$anchor=anchor; : let(spin_dir = rot(anchor_data[3],from=UP, to=-anchor_dir, p=BACK))
_compute_spin(anchor_dir,spin_dir);
for(align_ind = idx(align_list)){ for(align_ind = idx(align_list)){
align = is_undef(align_list[align_ind]) ? undef align = is_undef(align_list[align_ind]) ? undef
: assert(is_vector(align_list[align_ind],2) || is_vector(align_list[align_ind],3), "align direction must be a 2-vector or 3-vector") : assert(is_vector(align_list[align_ind],2) || is_vector(align_list[align_ind],3), "align direction must be a 2-vector or 3-vector")
@ -959,18 +961,16 @@ module attach(parent, child, overlap, align, spin=0, norot, inset=0, shiftout=0,
: two_d ? rot(to=reference, from=anchor,p=align) : two_d ? rot(to=reference, from=anchor,p=align)
: apply(zrot(-factor*spin)*frame_map(x=reference, z=BACK)*frame_map(x=factor*anchor, z=startdir, reverse=true), : apply(zrot(-factor*spin)*frame_map(x=reference, z=BACK)*frame_map(x=factor*anchor, z=startdir, reverse=true),
align); align);
spinaxis = two_d? UP : anchor_dir; spinaxis = two_d? UP : anchor_dir;
olap = - overlap * reference - inset*inset_dir + shiftout * (inset_dir + factor*reference); olap = - overlap * reference - inset*inset_dir + shiftout * (inset_dir + factor*reference);
if (norot || (approx(anchor_dir,reference) && anchor_spin==0))
if (norot || (approx(anchor_dir,reference) && anchor_spin==0)) {
translate(pos) rot(v=spinaxis,a=factor*spin) translate(olap) default_tag("remove",inside) children(); translate(pos) rot(v=spinaxis,a=factor*spin) translate(olap) default_tag("remove",inside) children();
} else { else
translate(pos) translate(pos)
rot(v=spinaxis,a=factor*spin) rot(v=spinaxis,a=factor*spin)
rot(anchor_spin,from=reference,to=anchor_dir){ rot(anchor_spin,from=reference,to=anchor_dir)
translate(olap) translate(olap)
default_tag("remove",inside) children();}} default_tag("remove",inside) children();
} }
} }
} }

View file

@ -466,12 +466,15 @@ function bezpath_curve(bezpath, splinesteps=16, N=3, endpoint=true) =
assert(len(bezpath)%N == 1, str("A degree ",N," bezier path should have a multiple of ",N," points in it, plus 1.")) assert(len(bezpath)%N == 1, str("A degree ",N," bezier path should have a multiple of ",N," points in it, plus 1."))
let( let(
segs = (len(bezpath)-1) / N, segs = (len(bezpath)-1) / N,
step = 1 / splinesteps step = 1 / splinesteps,
) [ path = [
for (seg = [0:1:segs-1]) for (seg = [0:1:segs-1])
each bezier_points(select(bezpath, seg*N, (seg+1)*N), [0:step:1-step/2]), each bezier_points(select(bezpath, seg*N, (seg+1)*N), [0:step:1-step/2]),
if (endpoint) last(bezpath) if (endpoint) last(bezpath)
]; ],
is_closed = approx(path[0], last(path)),
out = path_merge_collinear(path, closed=is_closed)
) out;
// Function: bezpath_closest_point() // Function: bezpath_closest_point()