From fa58f33e6daff0a657643b9dfd4bfbd2cc2b0a90 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Fri, 23 Aug 2024 18:11:45 -0400 Subject: [PATCH] fix spin on wedge edges --- shapes3d.scad | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/shapes3d.scad b/shapes3d.scad index f6ee63b..0b25a1f 100644 --- a/shapes3d.scad +++ b/shapes3d.scad @@ -1147,10 +1147,15 @@ module wedge(size=[1, 1, 1], center, anchor, spin=0, orient=UP) size = scalar_vec3(size); anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]); vnf = wedge(size, anchor="origin"); + spindir = unit([0,-size.y,size.z]); + hypot_dir = unit([0,size.z,size.y],UP); + left_dir = unit(hypot_dir+LEFT); + right_dir = unit(hypot_dir+RIGHT); + hedge_spin=vector_angle(spindir,rot(from=UP,to=left_dir, p=BACK)); anchors = [ - named_anchor("hypot", CTR, unit([0,size.z,size.y],UP)), - named_anchor("hypot_left", [-size.x/2,0,0], unit(unit([0,size.z,size.y],UP)+LEFT)), - named_anchor("hypot_right", [size.x/2,0,0], unit(unit([0,size.z,size.y],UP)+RIGHT)), + named_anchor("hypot", CTR, hypot_dir, 180), + named_anchor("hypot_left", [-size.x/2,0,0], left_dir,-hedge_spin), + named_anchor("hypot_right", [size.x/2,0,0], right_dir,hedge_spin), ]; attachable(anchor,spin,orient, size=size, anchors=anchors) { if (size.z > 0) { @@ -1174,10 +1179,15 @@ function wedge(size=[1,1,1], center, anchor, spin=0, orient=UP) = [1,4,2], [2,4,5], [2,5,3], [0,2,3], ], vnf = [scale(size/2,p=pts), faces], + spindir = unit([0,-size.y,size.z]), + hypot_dir = unit([0,size.z,size.y],UP), + left_dir = unit(hypot_dir+LEFT), + right_dir = unit(hypot_dir+RIGHT), + hedge_spin=vector_angle(spindir,rot(from=UP,to=left_dir, p=BACK)), anchors = [ - named_anchor("hypot", CTR, unit([0,size.z,size.y],UP)), - named_anchor("hypot_left", [-size.x/2,0,0], unit(unit([0,size.z,size.y],UP)+LEFT)), - named_anchor("hypot_right", [size.x/2,0,0], unit(unit([0,size.z,size.y],UP)+RIGHT)), + named_anchor("hypot", CTR, hypot_dir, 180), + named_anchor("hypot_left", [-size.x/2,0,0], left_dir,-hedge_spin), + named_anchor("hypot_right", [size.x/2,0,0], right_dir,hedge_spin), ] ) reorient(anchor,spin,orient, size=size, anchors=anchors, p=vnf);