remove ALLNEG and fix rect errors due to bad get_anchor default doc

This commit is contained in:
Adrian Mariano 2021-11-11 22:55:03 -05:00
parent 8b5a02297a
commit bc431016fc
4 changed files with 12 additions and 20 deletions

View file

@ -161,14 +161,6 @@ DOWN = BOTTOM;
TOP = [ 0, 0, 1];
UP = TOP;
// Constant: ALLNEG
// Topics: Constants, Vectors
// See Also: LEFT, RIGHT, FRONT, BACK, UP, DOWN, CENTER
// Description: Vector pointing left, forwards, and down. [-1,-1,-1]
// Example(3D): Usage with `anchor`
// cuboid(20, anchor=ALLNEG);
ALLNEG = [-1, -1, -1]; // Vector pointing X-,Y-,Z-.
// Constant: CENTER
// Aliases: CTR
// Topics: Constants, Vectors

View file

@ -106,7 +106,7 @@ module square(size=1, center, anchor, spin) {
// move_copies(path) color("blue") circle(d=2,$fn=8);
module rect(size=1, center, rounding=0, chamfer=0, anchor, spin=0) {
size = is_num(size)? [size,size] : point2d(size);
anchor = point2d(get_anchor(anchor, center));
anchor = point2d(get_anchor(anchor, center, FRONT+LEFT, CENTER));
if (rounding==0 && chamfer==0) {
attachable(anchor,spin, two_d=true, size=size) {
square(size, center=true);
@ -128,7 +128,7 @@ function rect(size=1, center, rounding=0, chamfer=0, anchor, spin=0) =
assert(is_num(rounding) || len(rounding)==4)
let(
size = is_num(size)? [size,size] : point2d(size),
anchor = point2d(get_anchor(anchor, center)),
anchor = point2d(get_anchor(anchor, center, FRONT+LEFT, CENTER)),
complex = rounding!=0 || chamfer!=0
)
(rounding==0 && chamfer==0)? let(

View file

@ -29,7 +29,7 @@ use <builtins.scad>
// When called as a function, returns a [VNF](vnf.scad) for a cube.
// Arguments:
// size = The size of the cube.
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=ALLNEG`.
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=FRONT+LEFT+BOTTOM`.
// ---
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
@ -51,7 +51,7 @@ use <builtins.scad>
// vnf_polyhedron(vnf);
module cube(size=1, center, anchor, spin=0, orient=UP)
{
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG);
anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]);
size = scalar_vec3(size);
attachable(anchor,spin,orient, size=size) {
_cube(size, center=true);
@ -62,7 +62,7 @@ module cube(size=1, center, anchor, spin=0, orient=UP)
function cube(size=1, center, anchor, spin=0, orient=UP) =
let(
siz = scalar_vec3(size),
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG),
anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]),
unscaled = [
[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],
[-1,-1, 1],[1,-1, 1],[1,1, 1],[-1,1, 1],
@ -110,7 +110,7 @@ function cube(size=1, center, anchor, spin=0, orient=UP) =
// edges = Edges to mask. See [Specifying Edges](edges.scad#section-specifying-edges). Default: all edges.
// except = Edges to explicitly NOT mask. See [Specifying Edges](edges.scad#section-specifying-edges). Default: No edges.
// trimcorners = If true, rounds or chamfers corners where three chamfered/rounded edges meet. Default: `true`
// p1 = Align the cuboid's corner at `p1`, if given. Forces `anchor=ALLNEG`.
// p1 = Align the cuboid's corner at `p1`, if given. Forces `anchor=FRONT+LEFT+BOTTOM`.
// p2 = If given with `p1`, defines the cornerpoints of the cuboid.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#spin). Default: `0`
@ -243,11 +243,11 @@ module cuboid(
if (!is_undef(p1)) {
if (!is_undef(p2)) {
translate(pointlist_bounds([p1,p2])[0]) {
cuboid(size=v_abs(p2-p1), chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=ALLNEG) children();
cuboid(size=v_abs(p2-p1), chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=-[1,1,1]) children();
}
} else {
translate(p1) {
cuboid(size=size, chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=ALLNEG) children();
cuboid(size=size, chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=-[1,1,1]) children();
}
}
} else {
@ -895,7 +895,7 @@ function rect_tube(
// size = [width, thickness, height]
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=UP`.
// ---
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `ALLNEG`
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `FRONT+LEFT+BOTTOM`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
//
@ -908,7 +908,7 @@ function rect_tube(
module wedge(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
{
size = scalar_vec3(size);
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG);
anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]);
vnf = wedge(size, center=true);
attachable(anchor,spin,orient, size=size, size2=[size.x,0], shift=[0,-size.y/2]) {
if (size.z > 0) {
@ -922,7 +922,7 @@ module wedge(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
function wedge(size=[1,1,1], center, anchor, spin=0, orient=UP) =
let(
size = scalar_vec3(size),
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG),
anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]),
pts = [
[ 1,1,-1], [ 1,-1,-1], [ 1,-1,1],
[-1,1,-1], [-1,-1,-1], [-1,-1,1],

View file

@ -418,7 +418,7 @@ function all_defined(v,recursive=false) =
// Arguments:
// anchor = The anchor name or vector.
// center = If not `undef`, this overrides the value of `anchor`.
// uncentered = The value to return if `center` is not `undef` and evaluates as false. Default: ALLNEG
// uncentered = The value to return if `center` is not `undef` and evaluates as false. Default: BOTTOM
// dflt = The default value to return if both `anchor` and `center` are `undef`. Default: `CENTER`
// Example:
// anchr1 = get_anchor(undef, undef, BOTTOM, TOP); // Returns: [0, 0, 1] (TOP)