Merge pull request #1083 from adrianVmariano/master

fix degenerate trapezoid anchoring
This commit is contained in:
Revar Desmera 2023-03-20 21:03:16 -07:00 committed by GitHub
commit 3527daf45d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 14 deletions

View file

@ -755,6 +755,13 @@ module tag_scope(scope){
// Attachable objects should be tagged using {{tag()}}
// and non-attachable objects with {{force_tag()}}.
// .
// Remember when using tagged operations with that the operations don't happen in hierarchical order, since
// the point of tags is to break the hierarchy. If you tag an object with a keep tag, nothing will be
// subtracted from it, no matter where it appears because kept objects are unioned in at the end.
// If you want a child of an object tagged with a remove tag to stay in the model it may be
// better to give it a tag that is not a remove tag or a keep tag. Such an object *will* be subject to
// subtractions from other remove-tagged objects.
// .
// For a step-by-step explanation of attachments, see the [[Attachments Tutorial|Tutorial-Attachments]].
// Arguments:
// remove = String containing space delimited set of tag names of children to difference away. Default: `"remove"`
@ -2662,19 +2669,9 @@ function _find_anchor(anchor, geom) =
pos = default(override[0],point2d(cp) + lerp(frpt, bkpt, u) + point2d(offset)),
svec = point3d(line_normal(bkpt,frpt)*anchor.x),
vec = is_def(override[1]) ? override[1]
:
anchor.y < 0? (
anchor.x == 0? FWD :
size.x == 0? unit(-[shift,size.y], FWD) :
unit((point3d(svec) + FWD) / 2, FWD)
) :
anchor.y == 0? ( anchor.x == 0? BACK : svec ) :
( // anchor.y > 0
anchor.x == 0? BACK :
size2 == 0? unit([shift,size.y], BACK) :
unit((point3d(svec) + BACK) / 2, BACK)
)
: anchor.y == 0? ( anchor.x == 0? BACK : svec )
: anchor.x == 0? [0,anchor.y,0]
: unit((svec + [0,anchor.y,0]) / 2, [0,anchor.y,0])
) [anchor, pos, vec, 0]
) : type == "ellipse"? ( //r
let(

View file

@ -120,6 +120,7 @@ function cube(size=1, center, anchor, spin=0, orient=UP) =
// 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. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
// See Also: prismoid(), rounded_prism()
// Example: Simple regular cube.
// cuboid(40);
// Example: Cube with minimum cornerpoint given.
@ -598,7 +599,7 @@ function cuboid(
// 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`
//
// See Also: rounded_prism()
// See Also: cuboid(), rounded_prism()
//
// Example: Rectangular Pyramid
// prismoid([40,40], [0,0], h=20);