Add helper function

This commit is contained in:
maride 2017-12-21 15:17:43 +01:00
parent 07b2586a7e
commit d67673241e

View File

@ -25,21 +25,9 @@ module base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y) {
* base_plane(...) with rounded edges, using helper function __radius_cutout(...) * base_plane(...) with rounded edges, using helper function __radius_cutout(...)
*/ */
module round_base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius) { module round_base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y, radius) {
difference() { intersection() {
base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y); base_plane(width, height, hole_size, hole_spacing_x, hole_spacing_y);
__round_square(width, height, radius);
translate([width-radius, height-radius])
__radius_cutout(radius);
translate([radius, height-radius])
rotate([0, 0, 90])
__radius_cutout(radius);
translate([radius, radius])
rotate([0, 0, 180])
__radius_cutout(radius);
translate([width-radius, radius])
rotate([0, 0, 270])
__radius_cutout(radius);
} }
} }
@ -106,3 +94,23 @@ module __radius_cutout(radius) {
circle(radius, $fn=RESOLUTION); circle(radius, $fn=RESOLUTION);
} }
} }
/*
* Helper function for square with round edges
*/
module __round_square(width, height, radius) {
difference() {
square([width, height]);
translate([width-radius, height-radius])
__radius_cutout(radius);
translate([radius, height-radius])
rotate([0, 0, 90])
__radius_cutout(radius);
translate([radius, radius])
rotate([0, 0, 180])
__radius_cutout(radius);
translate([width-radius, radius])
rotate([0, 0, 270])
__radius_cutout(radius);
}
}