Removed slot(), arced_slot(). Fixed positional args ordering and docs.

This commit is contained in:
Garth Minette 2021-01-17 01:38:10 -08:00
parent 92417f0cbb
commit 8fb9ef222a
3 changed files with 327 additions and 280 deletions

View file

@ -306,7 +306,7 @@ function get_radius(r1, r2, r, d1, d2, d, dflt) =
// h = h.
// height = height.
// dflt = Value to return if other values are `undef`.
function get_height(h=undef,l=undef,height=undef,dflt=undef) =
function get_height(h,l,height,dflt) =
assert(num_defined([h,l,height])<=1,"You must specify only one of `l`, `h`, and `height`")
first_defined([h,l,height,dflt]);
@ -400,6 +400,8 @@ function get_named_args(positional, named,_undef=_undef) =
val != _undef ? val :
ass != [] ? positional[ass[0]] :
deft[idx] ];
// Function: scalar_vec3()
// Usage:
// scalar_vec3(v, <dflt>);

View file

@ -11,6 +11,17 @@
// Module: cuboid()
//
// Usage: Standard Cubes
// cuboid(size, <anchor=>, <spin=>, <orient=>);
// cuboid(size, p1=, ...);
// cuboid(p1=, p2=, ...);
// Usage: Chamfered Cubes
// cuboid(size, <chamfer=>, <edges=>, <except_edges=>, <trimcorners=>, ...);
// Usage: Rounded Cubes
// cuboid(size, <rounding=>, <edges=>, <except_edges=>, <trimcorners=>, ...);
// Usage: Attaching children
// cuboid(size, <anchor=>, ...) <attachments>;
//
// Description:
// Creates a cube or cuboid object, with optional chamfering or rounding.
// Negative chamfers and roundings can be applied to create external masks,
@ -18,6 +29,7 @@
//
// Arguments:
// size = The size of the cube.
// ---
// chamfer = Size of chamfer, inset from sides. Default: No chamfering.
// rounding = Radius of the edge rounding. Default: No rounding.
// edges = Edges to chamfer/round. See the docs for [`edges()`](edges.scad#edges) to see acceptable values. Default: All edges.
@ -311,6 +323,19 @@ module cuboid(
}
}
function cuboid(
size=[1,1,1],
p1, p2,
chamfer,
rounding,
edges=EDGES_ALL,
except_edges=[],
trimcorners=true,
anchor=CENTER,
spin=0,
orient=UP
) = no_function("cuboid");
// Section: Prismoids
@ -318,12 +343,19 @@ module cuboid(
// Function&Module: prismoid()
//
// Usage: As Module
// prismoid(size1, size2, h|l, [shift], [rounding], [chamfer]);
// prismoid(size1, size2, h|l, [shift], [rounding1], [rounding2], [chamfer1], [chamfer2]);
// Usage: Typical Prismoids
// prismoid(size1, size2, h|l, <shift>, ...);
// Usage: Attaching Children
// prismoid(size1, size2, h|l, <shift>, ...) <attachments>;
// Usage: Chamfered Prismoids
// prismoid(size1, size2, h|l, <chamfer=>, ...);
// prismoid(size1, size2, h|l, <chamfer1=>, <chamfer2=>, ...);
// Usage: Rounded Prismoids
// prismoid(size1, size2, h|l, <rounding=>, ...);
// prismoid(size1, size2, h|l, <rounding1=>, <rounding2=>, ...);
// Usage: As Function
// vnf = prismoid(size1, size2, h|l, [shift], [rounding], [chamfer]);
// vnf = prismoid(size1, size2, h|l, [shift], [rounding1], [rounding2], [chamfer1], [chamfer2]);
// vnf = prismoid(size1, size2, h|l, <shift>, <rounding>, <chamfer>);
// vnf = prismoid(size1, size2, h|l, <shift>, <rounding1>, <rounding2>, <chamfer1>, <chamfer2>);
//
// Description:
// Creates a rectangular prismoid shape with optional roundovers and chamfering.
@ -335,16 +367,17 @@ module cuboid(
// ```
//
// Arguments:
// size1 = [width, length] of the axis-negative end of the prism.
// size2 = [width, length] of the axis-positive end of the prism.
// size1 = [width, length] of the bottom end of the prism.
// size2 = [width, length] of the top end of the prism.
// h|l = Height of the prism.
// shift = [X,Y] amount to shift the center of the top with respect to the center of the bottom.
// rounding = The roundover radius for the edges of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual radii for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-]. Default: 0 (no rounding)
// rounding1 = The roundover radius for the bottom corners of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual radii for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-].
// rounding2 = The roundover radius for the top corners of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual radii for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-].
// chamfer = The chamfer size for the edges of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual chamfers for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-]. Default: 0 (no chamfer)
// chamfer1 = The chamfer size for the bottom corners of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual chamfers for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-].
// chamfer2 = The chamfer size for the top corners of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual chamfers for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-].
// shift = [X,Y] amount to shift the center of the top end with respect to the center of the bottom end.
// ---
// rounding = The roundover radius for the vertical-ish edges of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual radii for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-]. Default: 0 (no rounding)
// rounding1 = The roundover radius for the bottom of the vertical-ish edges of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual radii for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-].
// rounding2 = The roundover radius for the top of the vertical-ish edges of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual radii for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-].
// chamfer = The chamfer size for the vertical-ish edges of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual chamfers for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-]. Default: 0 (no chamfer)
// chamfer1 = The chamfer size for the bottom of the vertical-ish edges of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual chamfers for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-].
// chamfer2 = The chamfer size for the top of the vertical-ish edges of the prismoid. Requires including hull.scad. If given as a list of four numbers, gives individual chamfers for each corner, in the order [X+Y+,X-Y+,X-Y-,X+Y-].
// 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`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
@ -488,13 +521,29 @@ function prismoid(
// Module: rect_tube()
// Usage:
// rect_tube(size, wall, h, [center]);
// rect_tube(isize, wall, h, [center]);
// rect_tube(size, isize, h, [center]);
// rect_tube(size1, size2, wall, h, [center]);
// rect_tube(isize1, isize2, wall, h, [center]);
// rect_tube(size1, size2, isize1, isize2, h, [center]);
// Usage: Typical Rectangular Tubes
// rect_tube(h, size, isize, <center>, <shift>);
// rect_tube(h, size, wall=, <center=>);
// rect_tube(h, isize=, wall=, <center=>);
// Usage: Tapering Rectangular Tubes
// rect_tube(h, size1=, size2=, wall=, ...);
// rect_tube(h, isize1=, isize2=, wall=, ...);
// rect_tube(h, size1=, size2=, isize1=, isize2=, ...);
// Usage: Chamfered
// rect_tube(h, size, isize, chamfer=, ...);
// rect_tube(h, size, isize, chamfer1=, chamfer2= ...);
// rect_tube(h, size, isize, ichamfer=, ...);
// rect_tube(h, size, isize, ichamfer1=, ichamfer2= ...);
// rect_tube(h, size, isize, chamfer=, ichamfer=, ...);
// Usage: Rounded
// rect_tube(h, size, isize, rounding=, ...);
// rect_tube(h, size, isize, rounding1=, rounding2= ...);
// rect_tube(h, size, isize, irounding=, ...);
// rect_tube(h, size, isize, irounding1=, irounding2= ...);
// rect_tube(h, size, isize, rounding=, irounding=, ...);
// Usage: Attaching Children
// rect_tube(h, size, isize, ...) <attachments>;
//
// Description:
// Creates a rectangular or prismoid tube with optional roundovers and/or chamfers.
// You can only round or chamfer the vertical(ish) edges. For those edges, you can
@ -505,9 +554,12 @@ function prismoid(
// include <BOSL2/hull.scad>
// ```
// Arguments:
// h|l = The height or length of the rectangular tube. Default: 1
// size = The outer [X,Y] size of the rectangular tube.
// isize = The inner [X,Y] size of the rectangular tube.
// h|l = The height or length of the rectangular tube. Default: 1
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=UP`.
// shift = [X,Y] amount to shift the center of the top end with respect to the center of the bottom end.
// ---
// wall = The thickness of the rectangular tube wall.
// size1 = The [X,Y] side of the outside of the bottom of the rectangular tube.
// size2 = The [X,Y] side of the outside of the top of the rectangular tube.
@ -570,16 +622,14 @@ function prismoid(
// rounding2=[0,5,0,10], irounding2=[0,3,0,8]
// );
module rect_tube(
size, isize,
h, shift=[0,0], wall,
size1, size2,
isize1, isize2,
h, size, isize, center, shift=[0,0],
wall, size1, size2, isize1, isize2,
rounding=0, rounding1, rounding2,
irounding=0, irounding1, irounding2,
chamfer=0, chamfer1, chamfer2,
ichamfer=0, ichamfer1, ichamfer2,
anchor, spin=0, orient=UP,
center, l
l
) {
h = first_defined([h,l,1]);
assert(is_num(h), "l or h argument required.");
@ -646,17 +696,30 @@ module rect_tube(
}
}
function rect_tube(
h, size, isize, center, shift=[0,0],
wall, size1, size2, isize1, isize2,
rounding=0, rounding1, rounding2,
irounding=0, irounding1, irounding2,
chamfer=0, chamfer1, chamfer2,
ichamfer=0, ichamfer1, ichamfer2,
anchor, spin=0, orient=UP,
l
) = no_function("rect_tube");
// Module: right_triangle()
//
// Usage:
// right_triangle(size, [center]);
// right_triangle(size, <center>);
//
// Description:
// Creates a 3D right triangular prism with the hypotenuse in the X+Y+ quadrant.
//
// Arguments:
// 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`
// 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`
@ -682,6 +745,9 @@ module right_triangle(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
}
function right_triangle(size=[1,1,1], center, anchor, spin=0, orient=UP) =
no_function("right_triangle");
// Section: Cylindroids
@ -689,32 +755,34 @@ module right_triangle(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
// Module: cyl()
//
// Description:
// Creates cylinders in various anchors and orientations,
// with optional rounding and chamfers. You can use `r` and `l`
// interchangably, and all variants allow specifying size
// by either `r`|`d`, or `r1`|`d1` and `r2`|`d2`.
// Note that that chamfers and rounding cannot cross the
// midpoint of the cylinder's length.
// Creates cylinders in various anchorings and orientations, with optional rounding and chamfers.
// You can use `h` and `l` interchangably, and all variants allow specifying size by either `r`|`d`,
// or `r1`|`d1` and `r2`|`d2`. Note: the chamfers and rounding cannot be cumulatively longer than
// the cylinder's length.
//
// Usage: Normal Cylinders
// cyl(l|h, r|d, [circum], [realign], [center]);
// cyl(l|h, r1|d1, r2/d2, [circum], [realign], [center]);
// cyl(l|h, r, <center>, <circum=>, <realign=>);
// cyl(l|h, d=, ...);
// cyl(l|h, r1=, r2=, ...);
// cyl(l|h, d1=, d2=, ...);
//
// Usage: Chamferred Cylinders
// cyl(l|h, r|d, chamfer, [chamfang], [from_end], [circum], [realign], [center]);
// cyl(l|h, r|d, chamfer1, [chamfang1], [from_end], [circum], [realign], [center]);
// cyl(l|h, r|d, chamfer2, [chamfang2], [from_end], [circum], [realign], [center]);
// cyl(l|h, r|d, chamfer1, chamfer2, [chamfang1], [chamfang2], [from_end], [circum], [realign], [center]);
// cyl(l|h, r|d, chamfer=, <chamfang=>, <from_end=>, ...);
// cyl(l|h, r|d, chamfer1=, <chamfang1=>, <from_end=>, ...);
// cyl(l|h, r|d, chamfer2=, <chamfang2=>, <from_end=>, ...);
// cyl(l|h, r|d, chamfer1=, chamfer2=, <chamfang1=>, <chamfang2=>, <from_end=>, ...);
//
// Usage: Rounded End Cylinders
// cyl(l|h, r|d, rounding, [circum], [realign], [center]);
// cyl(l|h, r|d, rounding1, [circum], [realign], [center]);
// cyl(l|h, r|d, rounding2, [circum], [realign], [center]);
// cyl(l|h, r|d, rounding1, rounding2, [circum], [realign], [center]);
// cyl(l|h, r|d, rounding=, ...);
// cyl(l|h, r|d, rounding1=, ...);
// cyl(l|h, r|d, rounding2=, ...);
// cyl(l|h, r|d, rounding1=, rounding2=, ...);
//
// Arguments:
// l / h = Length of cylinder along oriented axis. (Default: 1.0)
// r = Radius of cylinder.
// l / h = Length of cylinder along oriented axis. Default: 1
// r = Radius of cylinder. Default: 1
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=DOWN`.
// ---
// r1 = Radius of the negative (X-, Y-, Z-) end of cylinder.
// r2 = Radius of the positive (X+, Y+, Z+) end of cylinder.
// d = Diameter of cylinder.
@ -722,20 +790,19 @@ module right_triangle(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
// d2 = Diameter of the positive (X+, Y+, Z+) end of cylinder.
// circum = If true, cylinder should circumscribe the circle of the given size. Otherwise inscribes. Default: `false`
// chamfer = The size of the chamfers on the ends of the cylinder. Default: none.
// chamfer1 = The size of the chamfer on the axis-negative end of the cylinder. Default: none.
// chamfer2 = The size of the chamfer on the axis-positive end of the cylinder. Default: none.
// chamfer1 = The size of the chamfer on the bottom end of the cylinder. Default: none.
// chamfer2 = The size of the chamfer on the top end of the cylinder. Default: none.
// chamfang = The angle in degrees of the chamfers on the ends of the cylinder.
// chamfang1 = The angle in degrees of the chamfer on the axis-negative end of the cylinder.
// chamfang2 = The angle in degrees of the chamfer on the axis-positive end of the cylinder.
// chamfang1 = The angle in degrees of the chamfer on the bottom end of the cylinder.
// chamfang2 = The angle in degrees of the chamfer on the top end of the cylinder.
// from_end = If true, chamfer is measured from the end of the cylinder, instead of inset from the edge. Default: `false`.
// rounding = The radius of the rounding on the ends of the cylinder. Default: none.
// rounding1 = The radius of the rounding on the axis-negative end of the cylinder.
// rounding2 = The radius of the rounding on the axis-positive end of the cylinder.
// rounding1 = The radius of the rounding on the bottom end of the cylinder.
// rounding2 = The radius of the rounding on the top end of the cylinder.
// realign = If true, rotate the cylinder by half the angle of one face.
// 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`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=DOWN`.
//
// Example: By Radius
// xdistribute(30) {
@ -784,14 +851,14 @@ module right_triangle(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
// }
//
module cyl(
l=undef, h=undef,
r=undef, r1=undef, r2=undef,
d=undef, d1=undef, d2=undef,
chamfer=undef, chamfer1=undef, chamfer2=undef,
chamfang=undef, chamfang1=undef, chamfang2=undef,
rounding=undef, rounding1=undef, rounding2=undef,
h, r, center,
l, r1, r2,
d, d1, d2,
chamfer, chamfer1, chamfer2,
chamfang, chamfang1, chamfang2,
rounding, rounding1, rounding2,
circum=false, realign=false, from_end=false,
center, anchor, spin=0, orient=UP
anchor, spin=0, orient=UP
) {
l = first_defined([l, h, 1]);
_r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=1);
@ -889,13 +956,17 @@ module cyl(
// Description:
// Creates a cylinder oriented along the X axis.
//
// Usage:
// xcyl(l|h, r|d, [anchor]);
// xcyl(l|h, r1|d1, r2|d2, [anchor]);
// Usage: Typical
// xcyl(l|h, r, <anchor=>);
// xcyl(l|h, d=, <anchor=>);
// xcyl(l|h, r1=|d1=, r2=|d2=, <anchor=>);
// Usage: Attaching Children
// xcyl(l|h, r, <anchor=>) <attachments>;
//
// Arguments:
// l / h = Length of cylinder along oriented axis. (Default: `1.0`)
// r = Radius of cylinder.
// l / h = Length of cylinder along oriented axis. Default: 1
// r = Radius of cylinder. Default: 1
// ---
// r1 = Optional radius of left (X-) end of cylinder.
// r2 = Optional radius of right (X+) end of cylinder.
// d = Optional diameter of cylinder. (use instead of `r`)
@ -914,7 +985,7 @@ module cyl(
// xcyl(l=35, d=20);
// xcyl(l=35, d1=30, d2=10);
// }
module xcyl(l=undef, r=undef, d=undef, r1=undef, r2=undef, d1=undef, d2=undef, h=undef, anchor=CENTER)
module xcyl(h, r, d, r1, r2, d1, d2, l, anchor=CENTER)
{
r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=1);
r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1);
@ -932,13 +1003,17 @@ module xcyl(l=undef, r=undef, d=undef, r1=undef, r2=undef, d1=undef, d2=undef, h
// Description:
// Creates a cylinder oriented along the Y axis.
//
// Usage:
// ycyl(l|h, r|d, [anchor]);
// ycyl(l|h, r1|d1, r2|d2, [anchor]);
// Usage: Typical
// ycyl(l|h, r, <anchor=>);
// ycyl(l|h, d=, <anchor=>);
// ycyl(l|h, r1=|d1=, r2=|d2=, <anchor=>);
// Usage: Attaching Children
// ycyl(l|h, r, <anchor=>) <attachments>;
//
// Arguments:
// l / h = Length of cylinder along oriented axis. (Default: `1.0`)
// r = Radius of cylinder.
// ---
// r1 = Radius of front (Y-) end of cone.
// r2 = Radius of back (Y+) end of one.
// d = Diameter of cylinder.
@ -957,7 +1032,7 @@ module xcyl(l=undef, r=undef, d=undef, r1=undef, r2=undef, d1=undef, d2=undef, h
// ycyl(l=35, d=20);
// ycyl(l=35, d1=30, d2=10);
// }
module ycyl(l, r, d, r1, r2, d1, d2, h, anchor=CENTER)
module ycyl(h, r, d, r1, r2, d1, d2, l, anchor=CENTER)
{
r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=1);
r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1);
@ -975,13 +1050,17 @@ module ycyl(l, r, d, r1, r2, d1, d2, h, anchor=CENTER)
// Description:
// Creates a cylinder oriented along the Z axis.
//
// Usage:
// zcyl(l|h, r|d, [anchor]);
// zcyl(l|h, r1|d1, r2|d2, [anchor]);
// Usage: Typical
// zcyl(l|h, r, <anchor=>);
// zcyl(l|h, d=, <anchor=>);
// zcyl(l|h, r1=|d1=, r2=|d2=, <anchor=>);
// Usage: Attaching Children
// zcyl(l|h, r, <anchor=>) <attachments>;
//
// Arguments:
// l / h = Length of cylinder along oriented axis. (Default: 1.0)
// r = Radius of cylinder.
// ---
// r1 = Radius of front (Y-) end of cone.
// r2 = Radius of back (Y+) end of one.
// d = Diameter of cylinder.
@ -1000,7 +1079,7 @@ module ycyl(l, r, d, r1, r2, d1, d2, h, anchor=CENTER)
// zcyl(l=35, d=20);
// zcyl(l=35, d1=30, d2=10);
// }
module zcyl(l=undef, r=undef, d=undef, r1=undef, r2=undef, d1=undef, d2=undef, h=undef, anchor=CENTER)
module zcyl(h, r, d, r1, r2, d1, d2, l, anchor=CENTER)
{
cyl(l=l, h=h, r=r, r1=r1, r2=r2, d=d, d1=d1, d2=d2, orient=UP, anchor=anchor) children();
}
@ -1012,27 +1091,32 @@ module zcyl(l=undef, r=undef, d=undef, r1=undef, r2=undef, d1=undef, d2=undef, h
// Description:
// Makes a hollow tube with the given outer size and wall thickness.
//
// Usage:
// tube(h|l, ir|id, wall, [realign]);
// tube(h|l, or|od, wall, [realign]);
// tube(h|l, ir|id, or|od, [realign]);
// tube(h|l, ir1|id1, ir2|id2, wall, [realign]);
// tube(h|l, or1|od1, or2|od2, wall, [realign]);
// tube(h|l, ir1|id1, ir2|id2, or1|od1, or2|od2, [realign]);
// Usage: Typical
// tube(h|l, or, ir, <center>, <realign=>);
// tube(h|l, or=|od=, ir=|id=, ...);
// tube(h|l, ir|id, wall, ...);
// tube(h|l, or|od, wall, ...);
// tube(h|l, ir1|id1, ir2|id2, wall, ...);
// tube(h|l, or1|od1, or2|od2, wall, ...);
// tube(h|l, ir1|id1, ir2|id2, or1|od1, or2|od2, <realign>);
// Usage: Attaching Children
// tube(h|l, or, ir, <center>) <attachments>;
//
// Arguments:
// h / l = height of tube. (Default: 1)
// or = Outer radius of tube.
// or1 = Outer radius of bottom of tube. (Default: value of r)
// or2 = Outer radius of top of tube. (Default: value of r)
// h / l = height of tube. Default: 1
// or = Outer radius of tube. Default: 1
// ir = Inner radius of tube.
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=DOWN`.
// ---
// od = Outer diameter of tube.
// id = Inner diameter of tube.
// wall = horizontal thickness of tube wall. Default 0.5
// or1 = Outer radius of bottom of tube. Default: value of r)
// or2 = Outer radius of top of tube. Default: value of r)
// od1 = Outer diameter of bottom of tube.
// od2 = Outer diameter of top of tube.
// wall = horizontal thickness of tube wall. (Default 0.5)
// ir = Inner radius of tube.
// ir1 = Inner radius of bottom of tube.
// ir2 = Inner radius of top of tube.
// id = Inner diameter of tube.
// id1 = Inner diameter of bottom of tube.
// id2 = Inner diameter of top of tube.
// realign = If true, rotate the tube by half the angle of one face.
@ -1054,34 +1138,22 @@ module zcyl(l=undef, r=undef, d=undef, r1=undef, r2=undef, d1=undef, d2=undef, h
// Example: Standard Connectors
// tube(h=30, or=40, wall=5) show_anchors();
module tube(
h, wall=undef,
r=undef, r1=undef, r2=undef,
d=undef, d1=undef, d2=undef,
or=undef, or1=undef, or2=undef,
od=undef, od1=undef, od2=undef,
ir=undef, id=undef, ir1=undef,
ir2=undef, id1=undef, id2=undef,
anchor, spin=0, orient=UP,
center, realign=false, l
h, or, ir, center,
od, id, wall,
or1, or2, od1, od2,
ir1, ir2, id1, id2,
realign=false, l,
anchor, spin=0, orient=UP
) {
function safe_add(x,wall) = is_undef(x)? undef : x+wall;
h = first_defined([h,l,1]);
orr1 = get_radius(
r=first_defined([or1, r1, or, r]),
d=first_defined([od1, d1, od, d]),
dflt=undef
);
orr2 = get_radius(
r=first_defined([or2, r2, or, r]),
d=first_defined([od2, d2, od, d]),
dflt=undef
);
orr1 = get_radius(r1=or1, r=or, d1=od1, d=od, dflt=undef);
orr2 = get_radius(r1=or2, r=or, d1=od2, d=od, dflt=undef);
irr1 = get_radius(r1=ir1, r=ir, d1=id1, d=id, dflt=undef);
irr2 = get_radius(r1=ir2, r=ir, d1=id2, d=id, dflt=undef);
r1 = is_num(orr1)? orr1 : is_num(irr1)? irr1+wall : undef;
r2 = is_num(orr2)? orr2 : is_num(irr2)? irr2+wall : undef;
ir1 = is_num(irr1)? irr1 : is_num(orr1)? orr1-wall : undef;
ir2 = is_num(irr2)? irr2 : is_num(orr2)? orr2-wall : undef;
r1 = default(orr1, u_add(irr1,wall));
r2 = default(orr2, u_add(irr2,wall));
ir1 = default(irr1, u_sub(orr1,wall));
ir2 = default(irr2, u_sub(orr2,wall));
assert(ir1 <= r1, "Inner radius is larger than outer radius.");
assert(ir2 <= r2, "Inner radius is larger than outer radius.");
sides = segs(max(r1,r2));
@ -1100,18 +1172,54 @@ module tube(
// Module: torus()
//
// Usage: Typical
// torus(r_maj|d_maj, r_min|d_min, <center>, ...);
// torus(or|od, ir|id, ...);
// torus(r_maj|d_maj, or|od, ...);
// torus(r_maj|d_maj, ir|id, ...);
// torus(r_min|d_min, or|od, ...);
// torus(r_min|d_min, ir|id, ...);
// Usage: Attaching Children
// torus(or|od, ir|id, ...) <attachments>;;
//
// Description:
// Creates a torus shape.
//
// Usage:
// torus(r|d, r2|d2);
// torus(or|od, ir|id);
// Figure(2D,Med):
// module text3d(t,size=8) text(text=t,size=size,font="Helvetica", halign="center",valign="center");
// module dashcirc(r,start=0,angle=359.9,dashlen=5) let(step=360*dashlen/(2*r*PI)) for(a=[start:step:start+angle]) stroke(arc(r=r,start=a,angle=step/2));
// r = 75; r2 = 30;
// down(r2+0.1) #torus(r_maj=r, r_min=r2, $fn=72);
// color("blue") linear_extrude(height=0.01) {
// dashcirc(r=r,start=15,angle=45);
// dashcirc(r=r-r2, start=90+15, angle=60);
// dashcirc(r=r+r2, start=180+45, angle=30);
// dashcirc(r=r+r2, start=15, angle=30);
// }
// rot(240) color("blue") linear_extrude(height=0.01) {
// stroke([[0,0],[r+r2,0]], endcaps="arrow2",width=2);
// right(r) fwd(9) rot(-240) text3d("or",size=10);
// }
// rot(135) color("blue") linear_extrude(height=0.01) {
// stroke([[0,0],[r-r2,0]], endcaps="arrow2",width=2);
// right((r-r2)/2) back(8) rot(-135) text3d("ir",size=10);
// }
// rot(45) color("blue") linear_extrude(height=0.01) {
// stroke([[0,0],[r,0]], endcaps="arrow2",width=2);
// right(r/2) back(8) text3d("r_maj",size=9);
// }
// rot(30) color("blue") linear_extrude(height=0.01) {
// stroke([[r,0],[r+r2,0]], endcaps="arrow2",width=2);
// right(r+r2/2) fwd(8) text3d("r_min",size=7);
// }
//
// Arguments:
// r = major radius of torus ring. (use with of 'r2', or 'd2')
// r2 = minor radius of torus ring. (use with of 'r', or 'd')
// d = major diameter of torus ring. (use with of 'r2', or 'd2')
// d2 = minor diameter of torus ring. (use with of 'r', or 'd')
// r_maj = major radius of torus ring. (use with of 'r_min', or 'd_min')
// r_min = minor radius of torus ring. (use with of 'r_maj', or 'd_maj')
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=DOWN`.
// ---
// d_maj = major diameter of torus ring. (use with of 'r_min', or 'd_min')
// d_min = minor diameter of torus ring. (use with of 'r_maj', or 'd_maj')
// or = outer radius of the torus. (use with 'ir', or 'id')
// ir = inside radius of the torus. (use with 'or', or 'od')
// od = outer diameter of the torus. (use with 'ir' or 'id')
@ -1121,23 +1229,35 @@ module tube(
//
// Example:
// // These all produce the same torus.
// torus(r=22.5, r2=7.5);
// torus(d=45, d2=15);
// torus(r_maj=22.5, r_min=7.5);
// torus(d_maj=45, d_min=15);
// torus(or=30, ir=15);
// torus(od=60, id=30);
// torus(d_maj=45, id=30);
// torus(d_maj=45, od=60);
// torus(d_min=15, id=30);
// torus(d_min=15, od=60);
// Example: Standard Connectors
// torus(od=60, id=30) show_anchors();
module torus(
r=undef, d=undef,
r2=undef, d2=undef,
or=undef, od=undef,
ir=undef, id=undef,
center, anchor, spin=0, orient=UP
r_maj, r_min, center,
d_maj, d_min,
or, od, ir, id,
anchor, spin=0, orient=UP
) {
orr = get_radius(r=or, d=od, dflt=1.0);
irr = get_radius(r=ir, d=id, dflt=0.5);
majrad = get_radius(r=r, d=d, dflt=(orr+irr)/2);
minrad = get_radius(r=r2, d=d2, dflt=(orr-irr)/2);
_or = get_radius(r=or, d=od, dflt=undef);
_ir = get_radius(r=ir, d=id, dflt=undef);
_r_maj = get_radius(r=r_maj, d=d_maj, dflt=undef);
_r_min = get_radius(r=r_min, d=d_min, dflt=undef);
majrad = is_finite(_r_maj)? _r_maj :
is_finite(_ir) && is_finite(_or)? (_or + _ir)/2 :
is_finite(_ir) && is_finite(_r_min)? (_ir + _r_min) :
is_finite(_or) && is_finite(_r_min)? (_or - _r_min) :
assert(false, "Bad Parameters");
minrad = is_finite(_r_min)? _r_min :
is_finite(_ir)? (majrad - _ir) :
is_finite(_or)? (_or - majrad) :
assert(false, "Bad Parameters");
anchor = get_anchor(anchor, center, BOT, CENTER);
attachable(anchor,spin,orient, r=(majrad+minrad), l=minrad*2) {
rotate_extrude(convexity=4) {
@ -1153,10 +1273,12 @@ module torus(
// Function&Module: spheroid()
// Usage: As Module
// spheroid(r|d, [circum], [style])
// Usage: Typical
// spheroid(r|d, <circum>, <style>);
// Usage: Attaching Children
// spheroid(r|d, <circum>, <style>) <attachments>;
// Usage: As Function
// vnf = spheroid(r|d, [circum], [style])
// vnf = spheroid(r|d, <circum>, <style>);
// Description:
// Creates a spheroid object, with support for anchoring and attachments.
// This is a drop-in replacement for the built-in `sphere()` module.
@ -1171,9 +1293,10 @@ module torus(
// - `style="icosa"` forms a sphere by subdividing an icosahedron (20-sided platonic solid). This makes even more uniform faces over the entirety of the sphere. The effective `$fn` value is quantized to a multiple of 5, though.
// Arguments:
// r = Radius of the spheroid.
// style = The style of the spheroid's construction. One of "orig", "aligned", "stagger", "octa", or "icosa". Default: "aligned"
// ---
// d = Diameter of the spheroid.
// circum = If true, the spheroid is made large enough to circumscribe the sphere of the ideal side. Otherwise inscribes. Default: false (inscribes)
// style = The style of the spheroid's construction. One of "orig", "aligned", "stagger", "octa", or "icosa". Default: "aligned"
// 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`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
@ -1206,7 +1329,7 @@ module torus(
// Example: Called as Function
// vnf = spheroid(d=100, style="icosa");
// vnf_polyhedron(vnf);
module spheroid(r, d, circum=false, style="aligned", anchor=CENTER, spin=0, orient=UP)
module spheroid(r, style="aligned", d, circum=false, anchor=CENTER, spin=0, orient=UP)
{
r = get_radius(r=r, d=d, dflt=1);
sides = segs(r);
@ -1229,7 +1352,7 @@ module spheroid(r, d, circum=false, style="aligned", anchor=CENTER, spin=0, orie
}
function spheroid(r, d, circum=false, style="aligned", anchor=CENTER, spin=0, orient=UP) =
function spheroid(r, style="aligned", d, circum=false, anchor=CENTER, spin=0, orient=UP) =
let(
r = get_radius(r=r, d=d, dflt=1),
hsides = segs(r),
@ -1376,15 +1499,19 @@ function spheroid(r, d, circum=false, style="aligned", anchor=CENTER, spin=0, or
// Description:
// Makes a teardrop shape in the XZ plane. Useful for 3D printable holes.
//
// Usage:
// teardrop(r|d, l|h, [ang], [cap_h])
// Usage: Typical
// teardrop(h|l, r, <ang>, <cap_h>, ...);
// teardrop(h|l, d=, <ang=>, <cap_h=>, ...);
// Usage: Attaching Children
// teardrop(h|l, r, ...) <attachments>;
//
// Arguments:
// r = Radius of circular part of teardrop. (Default: 1)
// h / l = Thickness of teardrop. Default: 1
// r = Radius of circular part of teardrop. Default: 1
// ang = Angle of hat walls from the Z axis. Default: 45 degrees
// cap_h = If given, height above center where the shape will be truncated. Default: `undef` (no truncation)
// ---
// d = Diameter of circular portion of bottom. (Use instead of r)
// l = Thickness of teardrop. (Default: 1)
// ang = Angle of hat walls from the Z axis. (Default: 45 degrees)
// cap_h = If given, height above center where the shape will be truncated.
// 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`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
@ -1395,12 +1522,17 @@ function spheroid(r, d, circum=false, style="aligned", anchor=CENTER, spin=0, or
// teardrop(r=30, h=10, ang=30, cap_h=40);
// Example: Close Crop
// teardrop(r=30, h=10, ang=30, cap_h=20);
module teardrop(r=undef, d=undef, l=undef, h=undef, ang=45, cap_h=undef, anchor=CENTER, spin=0, orient=UP)
// Example: Standard Connectors
// teardrop(r=30, h=10, ang=30) show_anchors();
module teardrop(h, r, ang=45, cap_h, d, l, anchor=CENTER, spin=0, orient=UP)
{
r = get_radius(r=r, d=d, dflt=1);
l = first_defined([l, h, 1]);
size = [r*2,l,r*2];
attachable(anchor,spin,orient, size=size) {
maxd = 3*r/tan(ang);
anchors = [
["cap", [0,0,default(cap_h,maxd)], UP, 0]
];
attachable(anchor,spin,orient, r=r, l=l, axis=BACK, anchors=anchors) {
rot(from=UP,to=FWD) {
if (l > 0) {
linear_extrude(height=l, center=true, slices=2) {
@ -1419,37 +1551,42 @@ module teardrop(r=undef, d=undef, l=undef, h=undef, ang=45, cap_h=undef, anchor=
// Creates a sphere with a conical hat, to make a 3D teardrop.
//
// Usage:
// onion(r|d, [maxang], [cap_h]);
// onion(r|d, <ang>, <cap_h>);
// Usage: Typical
// onion(r, <ang>, <cap_h>, ...);
// onion(d=, <ang=>, <cap_h=>, ...);
// Usage: Attaching Children
// onion(r, ...) <attachments>;
//
// Arguments:
// r = radius of spherical portion of the bottom. (Default: 1)
// r = radius of spherical portion of the bottom. Default: 1
// ang = Angle of cone on top from vertical. Default: 45 degrees
// cap_h = If given, height above sphere center to truncate teardrop shape. Default: `undef` (no truncation)
// ---
// d = diameter of spherical portion of bottom.
// cap_h = height above sphere center to truncate teardrop shape.
// maxang = angle of cone on top from vertical.
// 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`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
//
// Example: Typical Shape
// onion(r=30, maxang=30);
// onion(r=30, ang=30);
// Example: Crop Cap
// onion(r=30, maxang=30, cap_h=40);
// onion(r=30, ang=30, cap_h=40);
// Example: Close Crop
// onion(r=30, maxang=30, cap_h=20);
// onion(r=30, ang=30, cap_h=20);
// Example: Standard Connectors
// onion(r=30, maxang=30, cap_h=40) show_anchors();
module onion(cap_h=undef, r=undef, d=undef, maxang=45, h=undef, anchor=CENTER, spin=0, orient=UP)
// onion(r=30, ang=30, cap_h=40) show_anchors();
module onion(r, ang=45, cap_h, d, anchor=CENTER, spin=0, orient=UP)
{
r = get_radius(r=r, d=d, dflt=1);
h = first_defined([cap_h, h]);
maxd = 3*r/tan(maxang);
maxd = 3*r/tan(ang);
anchors = [
["cap", [0,0,h], UP, 0]
["cap", [0,0,default(cap_h,maxd)], UP, 0]
];
attachable(anchor,spin,orient, r=r, anchors=anchors) {
rotate_extrude(convexity=2) {
difference() {
teardrop2d(r=r, ang=maxang, cap_h=h);
teardrop2d(r=r, ang=ang, cap_h=cap_h);
left(r) square(size=[2*r,maxd], center=true);
}
}
@ -1472,8 +1609,8 @@ module nil() union(){}
// Module: noop()
//
// Description:
// Passes through the children passed to it, with no action at all.
// Useful while debugging when you want to replace a command.
// Passes through the children passed to it, with no action at all. Useful while debugging when
// you want to replace a command. This is an attachable non-object.
//
// Arguments:
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
@ -1486,14 +1623,19 @@ module noop(spin=0, orient=UP) attachable(CENTER,spin,orient, d=0.01) {nil(); ch
// Description:
// Creates a pie slice shape.
//
// Usage:
// pie_slice(ang, l|h, r|d, [center]);
// pie_slice(ang, l|h, r1|d1, r2|d2, [center]);
// Usage: Typical
// pie_slice(l|h, r, ang, <center>);
// pie_slice(l|h, d=, ang=, ...);
// pie_slice(l|h, r1=|d1=, r2=|d2=, ang=, ...);
// Usage: Attaching Children
// pie_slice(l|h, r, ang, ...) <attachments>;
//
// Arguments:
// ang = pie slice angle in degrees.
// h = height of pie slice.
// h / l = height of pie slice.
// r = radius of pie slice.
// ang = pie slice angle in degrees.
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=UP`.
// ---
// r1 = bottom radius of pie slice.
// r2 = top radius of pie slice.
// d = diameter of pie slice.
@ -1502,17 +1644,14 @@ module noop(spin=0, orient=UP) attachable(CENTER,spin,orient, d=0.01) {nil(); ch
// 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`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=UP`.
//
// Example: Cylindrical Pie Slice
// pie_slice(ang=45, l=20, r=30);
// Example: Conical Pie Slice
// pie_slice(ang=60, l=20, d1=50, d2=70);
module pie_slice(
ang=30, l=undef,
r=undef, r1=undef, r2=undef,
d=undef, d1=undef, d2=undef,
h=undef, center,
h, r, ang=30, center,
r1, r2, d, d1, d2, l,
anchor, spin=0, orient=UP
) {
l = first_defined([l, h, 1]);
@ -1540,15 +1679,19 @@ module pie_slice(
// Creates a shape that can be unioned into a concave joint between two faces, to fillet them.
// Center this part along the concave edge to be chamfered and union it in.
//
// Usage:
// interior_fillet(l, r|d, [ang], [overlap]);
// Usage: Typical
// interior_fillet(l, r, <ang>, <overlap>, ...);
// interior_fillet(l, d=, <ang=>, <overlap=>, ...);
// Usage: Attaching Children
// interior_fillet(l, r, <ang>, <overlap>, ...) <attachments>;
//
// Arguments:
// l = Length of edge to fillet.
// r = Radius of fillet.
// d = Diameter of fillet.
// ang = Angle between faces to fillet.
// overlap = Overlap size for unioning with faces.
// ---
// d = Diameter of fillet.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `FRONT+LEFT`
// 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`
@ -1590,112 +1733,13 @@ module interior_fillet(l=1.0, r, ang=90, overlap=0.01, d, anchor=FRONT+LEFT, spi
}
// Module: slot()
//
// Description:
// Makes a linear slot with rounded ends, appropriate for bolts to slide along.
//
// Usage:
// slot(h, l, r|d, [center]);
// slot(h, p1, p2, r|d, [center]);
// slot(h, l, r1|d1, r2|d2, [center]);
// slot(h, p1, p2, r1|d1, r2|d2, [center]);
//
// Arguments:
// p1 = center of starting circle of slot.
// p2 = center of ending circle of slot.
// l = length of slot along the X axis.
// h = height of slot shape. (default: 10)
// r = radius of slot circle. (default: 5)
// r1 = bottom radius of slot cone.
// r2 = top radius of slot cone.
// d = diameter of slot circle.
// d1 = bottom diameter of slot cone.
// d2 = top diameter of slot cone.
//
// Example: Between Two Points
// slot([0,0,0], [50,50,0], r1=5, r2=10, h=5);
// Example: By Length
// slot(l=50, r1=5, r2=10, h=5);
module slot(
p1=undef, p2=undef, h=10, l=undef,
r=undef, r1=undef, r2=undef,
d=undef, d1=undef, d2=undef
) {
r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=5);
r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=5);
sides = quantup(segs(max(r1, r2)), 4);
// TODO: implement orient and anchors.
hull() line_of(p1=p1, p2=p2, l=l, n=2) cyl(l=h, r1=r1, r2=r2, center=true, $fn=sides);
}
// Module: arced_slot()
//
// Description:
// Makes an arced slot, appropriate for bolts to slide along.
//
// Usage:
// arced_slot(h, r|d, sr|sd, [sa], [ea], [center], [$fn2]);
// arced_slot(h, r|d, sr1|sd1, sr2|sd2, [sa], [ea], [center], [$fn2]);
//
// Arguments:
// cp = Centerpoint of slot arc. Default: `[0, 0, 0]`
// h = Height of slot arc shape. Default: `1`
// r = Radius of slot arc. Default: `0.5`
// d = Diameter of slot arc. Default: `1`
// sr = Radius of slot channel. Default: `0.5`
// sd = Diameter of slot channel. Default: `0.5`
// sr1 = Bottom radius of slot channel cone. Use instead of `sr`.
// sr2 = Top radius of slot channel cone. Use instead of `sr`.
// sd1 = Bottom diameter of slot channel cone. Use instead of `sd`.
// sd2 = Top diameter of slot channel cone. Use instead of `sd`.
// sa = Starting angle. Default: `0`
// ea = Ending angle. Default: `90`
// 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`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
// $fn2 = The `$fn` value to use on the small round endcaps. The major arcs are still based on `$fn`. Default: `$fn`
//
// Example(Med): Typical Arced Slot
// arced_slot(d=60, h=5, sd=10, sa=60, ea=280);
// Example(Med): Conical Arced Slot
// arced_slot(r=60, h=5, sd1=10, sd2=15, sa=45, ea=180);
module arced_slot(
r=undef, d=undef, h=1.0,
sr=undef, sr1=undef, sr2=undef,
sd=undef, sd1=undef, sd2=undef,
sa=0, ea=90, cp=[0,0,0],
anchor=TOP, spin=0, orient=UP,
$fn2 = undef
) {
r = get_radius(r=r, d=d, dflt=2);
sr1 = get_radius(r1=sr1, r=sr, d1=sd1, d=sd, dflt=2);
sr2 = get_radius(r1=sr2, r=sr, d1=sd2, d=sd, dflt=2);
fn_minor = first_defined([$fn2, $fn]);
da = ea - sa;
attachable(anchor,spin,orient, r1=r+sr1, r2=r+sr2, l=h) {
translate(cp) {
zrot(sa) {
difference() {
pie_slice(ang=da, l=h, r1=r+sr1, r2=r+sr2, orient=UP, anchor=CENTER);
cyl(h=h+0.1, r1=r-sr1, r2=r-sr2);
}
right(r) cyl(h=h, r1=sr1, r2=sr2, $fn=fn_minor);
zrot(da) right(r) cyl(h=h, r1=sr1, r2=sr2, $fn=fn_minor);
}
}
children();
}
}
// Function&Module: heightfield()
// Usage: As Module
// heightfield(data, <size>, <bottom>, <maxz>, <xrange>, <yrange>, <style>, <convexity>);
// heightfield(data, <size>, <bottom>, <maxz>, <xrange>, <yrange>, <style>, <convexity>, ...);
// Usage: Attaching Children
// heightfield(data, <size>, ...) <attachments>;
// Usage: As Function
// vnf = heightfield(data, <size>, <bottom>, <maxz>, <xrange>, <yrange>, <style>);
// vnf = heightfield(data, <size>, <bottom>, <maxz>, <xrange>, <yrange>, <style>, ...);
// Description:
// Given a regular rectangular 2D grid of scalar values, or a function literal, generates a 3D
// surface where the height at any given point is the scalar value for that position.
@ -1707,6 +1751,7 @@ module arced_slot(
// xrange = A range of values to iterate X over when calculating a surface from a function literal. Default: [-1 : 0.01 : 1]
// yrange = A range of values to iterate Y over when calculating a surface from a function literal. Default: [-1 : 0.01 : 1]
// style = The style of subdividing the quads into faces. Valid options are "default", "alt", and "quincunx". Default: "default"
// ---
// convexity = Max number of times a line could intersect a wall of the surface being formed. Module only. Default: 10
// 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`
@ -1728,7 +1773,7 @@ module arced_slot(
// Example(NORENDER): Heightfield by Function, with Specific Ranges
// fn = function (x,y) 2*cos(5*norm([x,y]));
// heightfield(size=[100,100], bottom=-20, data=fn, xrange=[-180:2:180], yrange=[-180:2:180]);
module heightfield(data, size=[100,100], xrange=[-1:0.04:1], yrange=[-1:0.04:1], bottom=-20, maxz=100, style="default", convexity=10, anchor=CENTER, spin=0, orient=UP)
module heightfield(data, size=[100,100], bottom=-20, maxz=100, xrange=[-1:0.04:1], yrange=[-1:0.04:1], style="default", convexity=10, anchor=CENTER, spin=0, orient=UP)
{
size = is_num(size)? [size,size] : point2d(size);
vnf = heightfield(data=data, size=size, xrange=xrange, yrange=yrange, bottom=bottom, maxz=maxz, style=style);
@ -1739,7 +1784,7 @@ module heightfield(data, size=[100,100], xrange=[-1:0.04:1], yrange=[-1:0.04:1],
}
function heightfield(data, size=[100,100], xrange=[-1:0.04:1], yrange=[-1:0.04:1], bottom=-20, maxz=100, style="default", anchor=CENTER, spin=0, orient=UP) =
function heightfield(data, size=[100,100], bottom=-20, maxz=100, xrange=[-1:0.04:1], yrange=[-1:0.04:1], style="default", anchor=CENTER, spin=0, orient=UP) =
assert(is_list(data) || is_function(data))
let(
size = is_num(size)? [size,size] : point2d(size),

View file

@ -6,7 +6,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,527];
BOSL_VERSION = [2,0,528];
// Section: BOSL Library Version Functions