fix translation of non-centered cylinderX/Y
This commit is contained in:
@@ -28,7 +28,7 @@ PowerHeight=2.0;
|
||||
|
||||
// offset from left edge of phone to left edge of 3.5mm audio jack
|
||||
AuxMinX=23.0;
|
||||
AuxMinZ=4.1;
|
||||
AuxMinZ=3.8;
|
||||
|
||||
UsbWidth=9.0;
|
||||
UsbHeight=3.5;
|
||||
|
@@ -1,12 +1,18 @@
|
||||
function _toRad(r=undef, d=undef) = (r != undef) ? r : d/2;
|
||||
|
||||
module translateIf(cond, amount) {
|
||||
if (cond) {
|
||||
translate(amount) children();
|
||||
} else {
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
/// cylinder() where `center=false` behaves like for `cube(center=false)`,
|
||||
/// i.e. circle center is not at (0, 0) but (r, r)
|
||||
module cylinderZ(d=undef, r=undef, h=undef, center=false) {
|
||||
if (center) {
|
||||
translateIf(!center, [_toRad(r=r, d=d), _toRad(r=r, d=d), 0]) {
|
||||
cylinder(d=d, r=r, h=h, center=center);
|
||||
} else {
|
||||
translate([_toRad(r=r, d=d), _toRad(r=r, d=d), 0]) cylinder(d=d, r=r, h=h, center=center);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +20,17 @@ module cylinderZ(d=undef, r=undef, h=undef, center=false) {
|
||||
/// and where `center=false` behaves like for `cube(center=false)`,
|
||||
/// i.e. circle center is not at (0, 0) but (r, r)
|
||||
module cylinderX(d=undef, r=undef, h=undef, center=false) {
|
||||
rotate(a=[0,-90,0]) cylinderZ(d=d, r=r, h=h, center=center);
|
||||
translateIf(!center, [0, _toRad(r=r, d=d), _toRad(r=r, d=d)]) {
|
||||
rotate(a=[0,-90,0]) cylinder(d=d, r=r, h=h, center=center);
|
||||
}
|
||||
}
|
||||
|
||||
/// cylinder() but with the axis on the y axis instead of the z axis
|
||||
/// and where `center=false` behaves like for `cube(center=false)`,
|
||||
/// i.e. circle center is not at (0, 0) but (r, r)
|
||||
module cylinderY(d=undef, r=undef, h=undef, center=false) {
|
||||
rotate(a=[-90,0,0]) cylinderZ(d=d, r=r, h=h, center=center);
|
||||
translateIf(!center, [_toRad(r=r, d=d), 0, _toRad(r=r, d=d)]) {
|
||||
rotate(a=[-90,0,0]) cylinder(d=d, r=r, h=h, center=center);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user