mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-01 13:50:33 +02:00
usage message fixes and doc tweaks
remove triangle area, optimize polygon_area for triangles
This commit is contained in:
87
masks3d.scad
87
masks3d.scad
@@ -15,7 +15,7 @@
|
||||
|
||||
// Module: chamfer_edge_mask()
|
||||
// Usage:
|
||||
// chamfer_edge_mask(l, chamfer, [excess]);
|
||||
// chamfer_edge_mask(l, chamfer, [excess]) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Creates a shape that can be used to chamfer a 90 degree edge.
|
||||
// Difference it from the object to be chamfered. The center of
|
||||
@@ -24,6 +24,7 @@
|
||||
// l = Length of mask.
|
||||
// chamfer = Size of chamfer.
|
||||
// excess = The extra amount to add to the length of the mask so that it differences away from other shapes cleanly. Default: `0.1`
|
||||
// ---
|
||||
// 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 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`
|
||||
@@ -40,6 +41,7 @@
|
||||
// edge_mask(TOP+RIGHT)
|
||||
// #chamfer_edge_mask(l=50, chamfer=10);
|
||||
// }
|
||||
function chamfer_edge_mask(l=1, chamfer=1, excess=0.1, anchor=CENTER, spin=0, orient=UP) = no_function("chamfer_edge_mask");
|
||||
module chamfer_edge_mask(l=1, chamfer=1, excess=0.1, anchor=CENTER, spin=0, orient=UP) {
|
||||
attachable(anchor,spin,orient, size=[chamfer*2, chamfer*2, l]) {
|
||||
cylinder(r=chamfer, h=l+excess, center=true, $fn=4);
|
||||
@@ -50,7 +52,7 @@ module chamfer_edge_mask(l=1, chamfer=1, excess=0.1, anchor=CENTER, spin=0, orie
|
||||
|
||||
// Module: chamfer_corner_mask()
|
||||
// Usage:
|
||||
// chamfer_corner_mask(chamfer);
|
||||
// chamfer_corner_mask(chamfer) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Creates a shape that can be used to chamfer a 90 degree corner.
|
||||
// Difference it from the object to be chamfered. The center of
|
||||
@@ -77,6 +79,7 @@ module chamfer_edge_mask(l=1, chamfer=1, excess=0.1, anchor=CENTER, spin=0, orie
|
||||
// Example: Anchors
|
||||
// chamfer_corner_mask(chamfer=20)
|
||||
// show_anchors();
|
||||
function chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) = no_function("chamfer_corner_mask");
|
||||
module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
|
||||
octahedron(chamfer*4, anchor=anchor, spin=spin, orient=orient) children();
|
||||
}
|
||||
@@ -84,7 +87,7 @@ module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
|
||||
|
||||
// Module: chamfer_cylinder_mask()
|
||||
// Usage:
|
||||
// chamfer_cylinder_mask(r|d, chamfer, [ang], [from_end])
|
||||
// chamfer_cylinder_mask(r|d=, chamfer, [ang], [from_end]) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Create a mask that can be used to bevel/chamfer the end of a cylindrical region.
|
||||
// Difference it from the end of the region to be chamfered. The center of the mask
|
||||
@@ -92,8 +95,9 @@ module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
|
||||
// to be chamfered.
|
||||
// Arguments:
|
||||
// r = Radius of cylinder to chamfer.
|
||||
// chamfer = Size of the edge chamfered, inset from edge.
|
||||
// ---
|
||||
// d = Diameter of cylinder to chamfer. Use instead of r.
|
||||
// chamfer = Size of the edge chamfered, inset from edge. (Default: 0.25)
|
||||
// ang = Angle of chamfer in degrees from vertical. (Default: 45)
|
||||
// from_end = If true, chamfer size is measured from end of cylinder. If false, chamfer is measured outset from the radius of the cylinder. (Default: false)
|
||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||
@@ -110,7 +114,8 @@ module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
|
||||
// up(50) chamfer_cylinder_mask(r=50, chamfer=10);
|
||||
// }
|
||||
// Example: Masking by Attachment
|
||||
module chamfer_cylinder_mask(r, d, chamfer=0.25, ang=45, from_end=false, anchor=CENTER, spin=0, orient=UP)
|
||||
function chamfer_cylinder_mask(r, chamfer, d, ang=45, from_end=false, anchor=CENTER, spin=0, orient=UP) = no_function("chamfer_cylinder_mask");
|
||||
module chamfer_cylinder_mask(r, chamfer, d, ang=45, from_end=false, anchor=CENTER, spin=0, orient=UP)
|
||||
{
|
||||
r = get_radius(r=r, d=d, dflt=1);
|
||||
ch = from_end? chamfer : opp_ang_to_adj(chamfer,ang);
|
||||
@@ -129,15 +134,16 @@ module chamfer_cylinder_mask(r, d, chamfer=0.25, ang=45, from_end=false, anchor=
|
||||
|
||||
// Module: rounding_edge_mask()
|
||||
// Usage:
|
||||
// rounding_edge_mask(l|h, r|d)
|
||||
// rounding_edge_mask(l|h, r1|d1, r2|d2)
|
||||
// rounding_edge_mask(l|h, r|d, [excess=]) [ATTACHMENTS];
|
||||
// rounding_edge_mask(l|h, r1=|d1=, r2=|d2=, [excess=]) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Creates a shape that can be used to round a vertical 90 degree edge.
|
||||
// Difference it from the object to be rounded. The center of the mask
|
||||
// object should align exactly with the edge to be rounded.
|
||||
// Arguments:
|
||||
// l = Length of mask.
|
||||
// l/h = Length of mask.
|
||||
// r = Radius of the rounding.
|
||||
// ---
|
||||
// r1 = Bottom radius of rounding.
|
||||
// r2 = Top radius of rounding.
|
||||
// d = Diameter of the rounding.
|
||||
@@ -172,6 +178,7 @@ module chamfer_cylinder_mask(r, d, chamfer=0.25, ang=45, from_end=false, anchor=
|
||||
// rounding_edge_mask(l=p.z, r=25);
|
||||
// }
|
||||
// }
|
||||
function rounding_edge_mask(l, r, r1, r2, d, d1, d2, excess=0.1, anchor=CENTER, spin=0, orient=UP, h=undef) = no_function("rounding_edge_mask");
|
||||
module rounding_edge_mask(l, r, r1, r2, d, d1, d2, excess=0.1, anchor=CENTER, spin=0, orient=UP, h=undef)
|
||||
{
|
||||
l = first_defined([l, h, 1]);
|
||||
@@ -203,15 +210,15 @@ module rounding_edge_mask(l, r, r1, r2, d, d1, d2, excess=0.1, anchor=CENTER, sp
|
||||
|
||||
// Module: rounding_corner_mask()
|
||||
// Usage:
|
||||
// rounding_corner_mask(r|d, [excess=], [style=]);
|
||||
// rounding_corner_mask(r|d, [excess=], [style=]) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Creates a shape that you can use to round 90 degree corners.
|
||||
// Difference it from the object to be rounded. The center of the mask
|
||||
// object should align exactly with the corner to be rounded.
|
||||
// Arguments:
|
||||
// r = Radius of corner rounding.
|
||||
// d = Diameter of corner rounding.
|
||||
// ---
|
||||
// d = Diameter of corner rounding.
|
||||
// excess = Extra size for the mask. Defaults: 0.1
|
||||
// style = The style of the sphere cutout's construction. One of "orig", "aligned", "stagger", "octa", or "icosa". Default: "octa"
|
||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||
@@ -235,6 +242,7 @@ module rounding_edge_mask(l, r, r1, r2, d, d1, d2, excess=0.1, anchor=CENTER, sp
|
||||
// corner_mask(TOP)
|
||||
// #rounding_corner_mask(r=20);
|
||||
// }
|
||||
function rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=0, orient=UP) = no_function("rounding_corner_mask");
|
||||
module rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=0, orient=UP)
|
||||
{
|
||||
r = get_radius(r=r, d=d, dflt=1);
|
||||
@@ -252,8 +260,8 @@ module rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=
|
||||
|
||||
// Module: rounding_angled_edge_mask()
|
||||
// Usage:
|
||||
// rounding_angled_edge_mask(h, r|d, [ang]);
|
||||
// rounding_angled_edge_mask(h, r1|d1, r2|d2, [ang]);
|
||||
// rounding_angled_edge_mask(h, r|d=, [ang=]) [ATTACHMENTS];
|
||||
// rounding_angled_edge_mask(h, r1=|d1=, r2=|d2=, [ang=]) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Creates a vertical mask that can be used to round the edge where two face meet, at any arbitrary
|
||||
// angle. Difference it from the object to be rounded. The center of the mask should align exactly
|
||||
@@ -261,12 +269,13 @@ module rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=
|
||||
// Arguments:
|
||||
// h = Height of vertical mask.
|
||||
// r = Radius of the rounding.
|
||||
// ---
|
||||
// r1 = Bottom radius of rounding.
|
||||
// r2 = Top radius of rounding.
|
||||
// d = Diameter of the rounding.
|
||||
// d1 = Bottom diameter of rounding.
|
||||
// d2 = Top diameter of rounding.
|
||||
// ang = Angle that the planes meet at.
|
||||
// ang = Angle that the planes meet at. Default: 90
|
||||
// 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 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`
|
||||
@@ -280,7 +289,8 @@ module rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=
|
||||
// pie_slice(ang=70, h=50, d=100, center=true);
|
||||
// #rounding_angled_edge_mask(h=51, r1=10, r2=25, ang=70, $fn=32);
|
||||
// }
|
||||
module rounding_angled_edge_mask(h=1.0, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER, spin=0, orient=UP)
|
||||
function rounding_angled_edge_mask(h, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER, spin=0, orient=UP) = no_function("rounding_angled_edge_mask");
|
||||
module rounding_angled_edge_mask(h, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER, spin=0, orient=UP)
|
||||
{
|
||||
function _mask_shape(r) = [
|
||||
for (i = [0:1:n]) let (a=90+ang+i*sweep/n) [r*cos(a)+x, r*sin(a)+r],
|
||||
@@ -316,15 +326,16 @@ module rounding_angled_edge_mask(h=1.0, r, r1, r2, d, d1, d2, ang=90, anchor=CEN
|
||||
|
||||
// Module: rounding_angled_corner_mask()
|
||||
// Usage:
|
||||
// rounding_angled_corner_mask(r|d, ang);
|
||||
// rounding_angled_corner_mask(r|d=, [ang]) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Creates a shape that can be used to round the corner of an angle.
|
||||
// Difference it from the object to be rounded. The center of the mask
|
||||
// object should align exactly with the point of the corner to be rounded.
|
||||
// Arguments:
|
||||
// r = Radius of the rounding.
|
||||
// ---
|
||||
// d = Diameter of the rounding.
|
||||
// ang = Angle between planes that you need to round the corner of.
|
||||
// ang = Angle between planes that you need to round the corner of. Default: 90
|
||||
// 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 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`
|
||||
@@ -334,6 +345,7 @@ module rounding_angled_edge_mask(h=1.0, r, r1, r2, d, d1, d2, ang=90, anchor=CEN
|
||||
// pie_slice(ang=ang, h=50, r=200, center=true);
|
||||
// up(50/2) #rounding_angled_corner_mask(r=20, ang=ang);
|
||||
// }
|
||||
function rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=UP) = no_function("rounding_angled_corner_mask");
|
||||
module rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=UP)
|
||||
{
|
||||
r = get_radius(r=r, d=d, dflt=1);
|
||||
@@ -362,16 +374,17 @@ module rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=U
|
||||
|
||||
// Module: rounding_cylinder_mask()
|
||||
// Usage:
|
||||
// rounding_cylinder_mask(r|d, rounding);
|
||||
// rounding_cylinder_mask(r|d=, rounding);
|
||||
// Description:
|
||||
// Create a mask that can be used to round the end of a cylinder.
|
||||
// Difference it from the cylinder to be rounded. The center of the
|
||||
// mask object should align exactly with the center of the end of the
|
||||
// cylinder to be rounded.
|
||||
// Arguments:
|
||||
// r = Radius of cylinder. (Default: 1.0)
|
||||
// d = Diameter of cylinder. (Default: 1.0)
|
||||
// rounding = Radius of the edge rounding. (Default: 0.25)
|
||||
// r = Radius of cylinder.
|
||||
// rounding = Radius of the edge rounding.
|
||||
// ---
|
||||
// d = Diameter of cylinder.
|
||||
// Example:
|
||||
// difference() {
|
||||
// cylinder(r=50, h=50, center=false);
|
||||
@@ -388,8 +401,10 @@ module rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=U
|
||||
// attach(TOP)
|
||||
// #rounding_cylinder_mask(d=30, rounding=5, $tags="mask");
|
||||
// }
|
||||
module rounding_cylinder_mask(r, rounding=0.25, d)
|
||||
function rounding_cylinder_mask(r, rounding, d) = no_function("rounding_cylinder_mask");
|
||||
module rounding_cylinder_mask(r, rounding, d)
|
||||
{
|
||||
no_children($children);
|
||||
r = get_radius(r=r, d=d, dflt=1);
|
||||
difference() {
|
||||
cyl(r=r+rounding, l=rounding*2, anchor=CENTER);
|
||||
@@ -401,7 +416,7 @@ module rounding_cylinder_mask(r, rounding=0.25, d)
|
||||
|
||||
// Module: rounding_hole_mask()
|
||||
// Usage:
|
||||
// rounding_hole_mask(r|d, rounding, [excess]);
|
||||
// rounding_hole_mask(r|d, rounding, [excess]) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Create a mask that can be used to round the edge of a circular hole.
|
||||
// Difference it from the hole to be rounded. The center of the
|
||||
@@ -410,7 +425,7 @@ module rounding_cylinder_mask(r, rounding=0.25, d)
|
||||
// Arguments:
|
||||
// r = Radius of hole.
|
||||
// d = Diameter of hole to rounding.
|
||||
// rounding = Radius of the rounding. (Default: 0.25)
|
||||
// rounding = Radius of the rounding.
|
||||
// excess = The extra thickness of the mask. Default: `0.1`.
|
||||
// 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 after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
@@ -429,7 +444,8 @@ module rounding_cylinder_mask(r, rounding=0.25, d)
|
||||
// cylinder(r=50, h=100.1, center=true);
|
||||
// up(50) rounding_hole_mask(r=50, rounding=10);
|
||||
// }
|
||||
module rounding_hole_mask(r, rounding=0.25, excess=0.1, d, anchor=CENTER, spin=0, orient=UP)
|
||||
function rounding_hole_mask(r, rounding, excess=0.1, d, anchor=CENTER, spin=0, orient=UP) = no_function("rounding_hole_mask");
|
||||
module rounding_hole_mask(r, rounding, excess=0.1, d, anchor=CENTER, spin=0, orient=UP)
|
||||
{
|
||||
r = get_radius(r=r, d=d, dflt=1);
|
||||
attachable(anchor,spin,orient, r=r+rounding, l=2*rounding) {
|
||||
@@ -448,7 +464,7 @@ module rounding_hole_mask(r, rounding=0.25, excess=0.1, d, anchor=CENTER, spin=0
|
||||
|
||||
// Module: teardrop_edge_mask()
|
||||
// Usage:
|
||||
// teardrop_edge_mask(r|d, [angle], [excess]);
|
||||
// teardrop_edge_mask(r|d=, [angle], [excess]);
|
||||
// Description:
|
||||
// Makes an apropriate 3D corner rounding mask that keeps within `angle` degrees of vertical.
|
||||
// Arguments:
|
||||
@@ -456,9 +472,6 @@ module rounding_hole_mask(r, rounding=0.25, excess=0.1, d, anchor=CENTER, spin=0
|
||||
// d = Diameter of the mask rounding.
|
||||
// angle = Maximum angle from vertical. Default: 45
|
||||
// excess = Excess mask size. Default: 0.1
|
||||
// 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 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`
|
||||
// Example(VPD=50,VPR=[55,0,120]):
|
||||
// teardrop_edge_mask(l=20, r=10, angle=40);
|
||||
// Example(VPD=300,VPR=[75,0,25]):
|
||||
@@ -469,7 +482,10 @@ module rounding_hole_mask(r, rounding=0.25, excess=0.1, d, anchor=CENTER, spin=0
|
||||
// corner_mask(BOT)
|
||||
// teardrop_corner_mask(r=10, angle=40);
|
||||
// }
|
||||
module teardrop_edge_mask(l, r, angle, excess=0.1, d, anchor=CENTER, spin=0, orient=UP) {
|
||||
function teardrop_edge_mask(l, r, angle, excess=0.1, d) = no_function("teardrop_edge_mask");
|
||||
module teardrop_edge_mask(l, r, angle, excess=0.1, d)
|
||||
{
|
||||
no_children($children);
|
||||
assert(is_num(l));
|
||||
assert(is_num(angle));
|
||||
assert(is_num(excess));
|
||||
@@ -484,17 +500,15 @@ module teardrop_edge_mask(l, r, angle, excess=0.1, d, anchor=CENTER, spin=0, ori
|
||||
|
||||
// Module: teardrop_corner_mask()
|
||||
// Usage:
|
||||
// teardrop_corner_mask(r|d, [angle], [excess]);
|
||||
// teardrop_corner_mask(r|d=, [angle], [excess]);
|
||||
// Description:
|
||||
// Makes an apropriate 3D corner rounding mask that keeps within `angle` degrees of vertical.
|
||||
// Arguments:
|
||||
// r = Radius of the mask rounding.
|
||||
// d = Diameter of the mask rounding.
|
||||
// angle = Maximum angle from vertical. Default: 45
|
||||
// excess = Excess mask size. Default: 0.1
|
||||
// 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 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`
|
||||
// ---
|
||||
// d = Diameter of the mask rounding.
|
||||
// Example:
|
||||
// teardrop_corner_mask(r=20, angle=40);
|
||||
// Example:
|
||||
@@ -505,7 +519,10 @@ module teardrop_edge_mask(l, r, angle, excess=0.1, d, anchor=CENTER, spin=0, ori
|
||||
// corner_mask(BOT)
|
||||
// teardrop_corner_mask(r=10, angle=40);
|
||||
// }
|
||||
module teardrop_corner_mask(r, angle, excess=0.1, d, anchor=CENTER, spin=0, orient=UP) {
|
||||
function teardrop_corner_mask(r, angle, excess=0.1, d) = no_function("teardrop_corner_mask");
|
||||
module teardrop_corner_mask(r, angle, excess=0.1, d)
|
||||
{
|
||||
no_children($children);
|
||||
assert(is_num(angle));
|
||||
assert(is_num(excess));
|
||||
assert(angle>0 && angle<90);
|
||||
|
Reference in New Issue
Block a user