Updated sweep_rounded to match parameters of other functions.

Also added additional assertions.
This commit is contained in:
Arthur Moore 2024-10-05 14:05:19 -04:00
parent a13f52676f
commit fa51cd0e7e
3 changed files with 16 additions and 6 deletions

View file

@ -321,7 +321,7 @@ module baseplate_lip(height=0, width=l_grid, length=l_grid) {
additional_height = height + BASEPLATE_CLEARANCE_HEIGHT;
sweep_rounded(width-2*BASEPLATE_OUTSIDE_RADIUS, length-2*BASEPLATE_OUTSIDE_RADIUS)
sweep_rounded([width-2*BASEPLATE_OUTSIDE_RADIUS, length-2*BASEPLATE_OUTSIDE_RADIUS])
translate([translation_x, additional_height, 0])
polygon(concat(BASEPLATE_LIP, [
[0, -additional_height],

View file

@ -324,7 +324,7 @@ module block_base(hole_options, off=0, size=[BASE_SIZE, BASE_SIZE], thumbscrew=f
render(convexity = 2)
difference() {
union() {
sweep_rounded(base_profile_size.x, base_profile_size.y)
sweep_rounded(base_profile_size)
translate([translation_x, 0, 0])
polygon(BASE_PROFILE);
@ -448,7 +448,7 @@ module profile_wall2(height_mm) {
module block_wall(gx, gy, l) {
translate([0,0,h_base])
sweep_rounded(gx*l-2*r_base-0.5-0.001, gy*l-2*r_base-0.5-0.001)
sweep_rounded([gx*l-2*r_base-0.5-0.001, gy*l-2*r_base-0.5-0.001])
children();
}

View file

@ -175,11 +175,21 @@ function affine_scale(vector) = [
/**
* @brief Create a rectangle with rounded corners by sweeping a 2d object along a path.
* Centered on origin.
* @Details Centered on origin.
* Result is on the X,Y plane.
* Expects children to be a 2D shape in Quardrant 1 of the X,Y plane.
* @param size Dimensions of the resulting object.
* Either a single number or [width, length]
*/
module sweep_rounded(width=10, length=10) {
assert(width > 0 && length > 0);
module sweep_rounded(size) {
assert((is_num(size) && size > 0) || (
is_list(size) && len(size) == 2 &&
is_num(size.x) && size.x > 0 && is_num(size.y) && size.y > 0
)
);
width = is_num(size) ? size : size.x;
length = is_num(size) ? size : size.y;
half_width = width/2;
half_length = length/2;
path_points = [