mirror of
https://github.com/kennetek/gridfinity-rebuilt-openscad.git
synced 2024-12-22 14:53:25 +00:00
Simplify rounded_square and make defaults match square
The default for square is center=false.
This commit is contained in:
parent
7aebad420c
commit
54f0f4f935
2 changed files with 22 additions and 12 deletions
|
@ -15,7 +15,7 @@ function is_even(number) = (number%2)==0;
|
||||||
* @details "size" accepts both the standard number or a 2d vector the same as `square`.
|
* @details "size" accepts both the standard number or a 2d vector the same as `square`.
|
||||||
* However, if passed a 3d vector, this will apply a `linear_extrude` to the resulting shape.
|
* However, if passed a 3d vector, this will apply a `linear_extrude` to the resulting shape.
|
||||||
*/
|
*/
|
||||||
module rounded_square(size, radius, center = true) {
|
module rounded_square(size, radius, center = false) {
|
||||||
assert(is_num(size) ||
|
assert(is_num(size) ||
|
||||||
(is_list(size) && (
|
(is_list(size) && (
|
||||||
(len(size) == 2 && is_num(size.x) && is_num(size.y)) ||
|
(len(size) == 2 && is_num(size.x) && is_num(size.y)) ||
|
||||||
|
@ -36,13 +36,23 @@ module rounded_square(size, radius, center = true) {
|
||||||
|
|
||||||
if (is_list(size) && len(size) == 3) {
|
if (is_list(size) && len(size) == 3) {
|
||||||
linear_extrude(size.z)
|
linear_extrude(size.z)
|
||||||
|
_internal_rounded_square_2d(size, radius, center);
|
||||||
|
} else {
|
||||||
|
_internal_rounded_square_2d(size, radius, center);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal module. Do not use. May be changed/removed at any time.
|
||||||
|
*/
|
||||||
|
module _internal_rounded_square_2d(size, radius, center) {
|
||||||
|
diameter = 2*radius;
|
||||||
|
if (is_list(size)) {
|
||||||
offset(radius)
|
offset(radius)
|
||||||
offset(-radius)
|
square([size.x-diameter, size.y-diameter], center = center);
|
||||||
square([size.x, size.y], center = center);
|
|
||||||
} else {
|
} else {
|
||||||
offset(radius)
|
offset(radius)
|
||||||
offset(-radius)
|
square(size-diameter, center = center);
|
||||||
square(size, center = center);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +60,7 @@ module rounded_square(size, radius, center = true) {
|
||||||
* @deprecated Use rounded_square(...)
|
* @deprecated Use rounded_square(...)
|
||||||
*/
|
*/
|
||||||
module rounded_rectangle(length, width, height, rad) {
|
module rounded_rectangle(length, width, height, rad) {
|
||||||
rounded_square([length, width, height], rad);
|
rounded_square([length, width, height], rad, center=true);
|
||||||
}
|
}
|
||||||
|
|
||||||
module copy_mirror(vec=[0,1,0]) {
|
module copy_mirror(vec=[0,1,0]) {
|
||||||
|
|
|
@ -161,7 +161,7 @@ module gridfinityBaseVase() {
|
||||||
intersection() {
|
intersection() {
|
||||||
block_base_blank(0);
|
block_base_blank(0);
|
||||||
translate([0,0,-h_base-1])
|
translate([0,0,-h_base-1])
|
||||||
rounded_rectangle(l_grid-0.5-0.005, l_grid-0.5-0.005, h_base*10, r_fo1+0.001);
|
rounded_square([l_grid-0.5-0.005, l_grid-0.5-0.005, h_base*10], r_fo1+0.001, center=true);
|
||||||
}
|
}
|
||||||
translate([0,0,0.01])
|
translate([0,0,0.01])
|
||||||
difference() {
|
difference() {
|
||||||
|
@ -220,16 +220,16 @@ module block_base_blank(o = 0) {
|
||||||
mirror([0,0,1]) {
|
mirror([0,0,1]) {
|
||||||
hull() {
|
hull() {
|
||||||
linear_extrude(h_base)
|
linear_extrude(h_base)
|
||||||
rounded_square(l_grid-o-0.05-2*r_c2-2*r_c1, r_fo3);
|
rounded_square(l_grid-o-0.05-2*r_c2-2*r_c1, r_fo3, center=true);
|
||||||
linear_extrude(h_base-r_c1)
|
linear_extrude(h_base-r_c1)
|
||||||
rounded_square(l_grid-o-0.05-2*r_c2, r_fo2);
|
rounded_square(l_grid-o-0.05-2*r_c2, r_fo2, center=true);
|
||||||
}
|
}
|
||||||
hull() {
|
hull() {
|
||||||
linear_extrude(r_c2)
|
linear_extrude(r_c2)
|
||||||
rounded_square(l_grid-o-0.05-2*r_c2, r_fo2);
|
rounded_square(l_grid-o-0.05-2*r_c2, r_fo2, center=true);
|
||||||
mirror([0,0,1])
|
mirror([0,0,1])
|
||||||
linear_extrude(d_bottom)
|
linear_extrude(d_bottom)
|
||||||
rounded_square(l_grid-o-0.05, r_fo1);
|
rounded_square(l_grid-o-0.05, r_fo1, center=true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ module transform_scoop() {
|
||||||
|
|
||||||
module block_vase(h = d_height*2) {
|
module block_vase(h = d_height*2) {
|
||||||
translate([0,0,-0.1])
|
translate([0,0,-0.1])
|
||||||
rounded_rectangle(gridx*l_grid-0.5-nozzle, gridy*l_grid-0.5-nozzle, h, r_base+0.01-nozzle/2);
|
rounded_square([gridx*l_grid-0.5-nozzle, gridy*l_grid-0.5-nozzle, h], r_base+0.01-nozzle/2, center=true);
|
||||||
}
|
}
|
||||||
|
|
||||||
module profile_x(x_f = 3) {
|
module profile_x(x_f = 3) {
|
||||||
|
|
Loading…
Reference in a new issue