Skip to content
Snippets Groups Projects
Commit bbf826ed authored by fxk8y's avatar fxk8y :spider:
Browse files

Add more specific centering options to roundRect(…)

parent 984cd48c
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,8 @@ module straightPipe(width, height, length, radius, strength, center=false) {
tz = center ? -l/2 : 0;
translate([0, 0, tz]) linear_extrude(l) difference() {
roundRect(w, h, r);
roundRect(w - _str*2, h - _str*2, r - _str);
roundRect(w, h, r, center=true);
roundRect(w - _str*2, h - _str*2, r - _str, center=true);
}
}
......@@ -34,8 +34,8 @@ module cornerPipe(width, height, diameter, angle, radius, strength, center=false
tz = center ? 0 : h/2;
translate([0, 0, tz]) rotate_extrude(angle=a, convexity=8) translate([w/2 + d/2, 0, 0]) difference() {
roundRect(w, h, r);
roundRect(w - _str*2, h - _str*2, r - _str);
roundRect(w, h, r, center=true);
roundRect(w - _str*2, h - _str*2, r - _str, center=true);
}
}
......@@ -64,8 +64,8 @@ module helixPipe(width, height, length, diameter, angle, radius, strength, cente
tz = center ? 0 : h/2;
translate([0, 0, tz]) linear_extrude(l, twist=a, convexity=8) translate([0, 0, 0]) difference() {
roundRect(w, h, r);
roundRect(w - _str*2, h - _str*2, r - _str);
roundRect(w, h, r, center=true);
roundRect(w - _str*2, h - _str*2, r - _str, center=true);
}
}
......@@ -85,14 +85,14 @@ module adapterPipe(
difference() {
// outer shell
hull() {
linear_extrude(epsilon) roundRect(w0, h0, r0);
translate([x_off, y_off, l - epsilon]) linear_extrude(epsilon) roundRect(w1, h1, r1);
linear_extrude(epsilon) roundRect(w0, h0, r0, center=true);
translate([x_off, y_off, l - epsilon]) linear_extrude(epsilon) roundRect(w1, h1, r1, center=true);
}
// inner hole
hull() {
linear_extrude(epsilon) roundRect(w0 - str0*2, h0 - str0*2, r0 - str0);
translate([x_off, y_off, l - epsilon]) linear_extrude(epsilon) roundRect(w1 - str1*2, h1 - str1*2, r1 - str1);
linear_extrude(epsilon) roundRect(w0 - str0*2, h0 - str0*2, r0 - str0, center=true);
translate([x_off, y_off, l - epsilon]) linear_extrude(epsilon) roundRect(w1 - str1*2, h1 - str1*2, r1 - str1, center=true);
}
}
}
......@@ -115,11 +115,11 @@ module crossNPipe(width, height, length, radius, strength, N, center=false) {
translate([0, 0, tz]) difference() {
for (rz=[0:360/N:360]) rotate([-90, 0, rz]) linear_extrude(l) {
roundRect(w, h, r);
roundRect(w, h, r, center=true);
}
for (rz=[0:360/N:360]) rotate([-90, 0, rz]) linear_extrude(l + epsilon) {
roundRect(w - _str*2, h - _str*2, r - _str);
roundRect(w - _str*2, h - _str*2, r - _str, center=true);
}
}
}
......
......@@ -28,15 +28,16 @@ module roundTri(w, h, r, style="inner") {
* TODO: Moar documentation!
*
*/
module roundRect(w, h, r) {
if (r > 0) {
_dw2 = (w - 2*r) / 2;
_dh2 = (h - 2*r) / 2;
hull() for (tx=[-_dw2, _dw2], ty=[-_dh2, _dh2]) translate([tx, ty, 0]) circle(r=r);
} else {
square([w, h], center=true);
}
module roundRect(w, h, r, center=false, centerX=false, centerY=false) {
tx = center || centerX ? -w/2 : 0;
ty = center || centerY ? -h/2 : 0;
translate([tx, ty, 0])
if (r > 0)
hull() for (_tx=[r, w-r], _ty=[r, h-r]) translate([_tx, _ty, 0]) circle(r=r);
else
square([w, h]);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment