From 0966e4eb00688344ee13d002b40e5916c3558635 Mon Sep 17 00:00:00 2001 From: Shy Date: Fri, 19 Jan 2024 20:17:44 +0100 Subject: [PATCH] New rounded-edges-algorithm. --- back.scad | 83 ++++++++++++----------- front.scad | 26 ++++--- svg/back hull.svg | 79 --------------------- svg/back outline.svg | 79 +++++++++++++++++++++ svg/{front hull.svg => front outline.svg} | 29 +++----- 5 files changed, 147 insertions(+), 149 deletions(-) delete mode 100644 svg/back hull.svg create mode 100644 svg/back outline.svg rename svg/{front hull.svg => front outline.svg} (52%) diff --git a/back.scad b/back.scad index 120078b..c9d7f96 100644 --- a/back.scad +++ b/back.scad @@ -59,10 +59,10 @@ */ // Abgerundete Außenkanten. -rounded_edges = true; +rounded_edges = false; // Abgeschrägte Außenkanten. -beveled_edges = false; +beveled_edges = true; // Temporäre Stützstrukturen in den Bohrungen. support = false; @@ -428,44 +428,6 @@ module outer() { import("./svg/back loops.svg"); } } -} - - -/************************************************************************* - * Die Hülle. * - *************************************************************************/ - -module body_back() { - if (rounded_edges || beveled_edges) { - intersection() { - union () { - outer(); - } - - color(color_top) - minkowski() { - linear_extrude(height=1) { - import("./svg/back hull.svg"); - } - - $fn = $preview ? 4 : 16; - if (beveled_edges) { - // Abgeschrägte Kanten. - cylinder(h=top+space, r1=0.5, r2=(top+space)/2); - } else { - // Abgerundete Kanten. - hull() { - for (i = [1:5]) { - translate([0, 0, i - 1]) - cylinder(r=sin(i * (90/5)) * 2, h=top + space); - } - } - } - } - } - } else { - outer(); - } // Stützen für die Buttons. if (button_support) { @@ -483,6 +445,47 @@ module body_back() { } } } +} + + +/************************************************************************* + * Die Hülle. * + *************************************************************************/ + +module body_back() { + if (rounded_edges || beveled_edges) { + difference() { + union () { + outer(); + } + + color(color_top) + translate([0, 0, -0.1]) + minkowski() { + linear_extrude(height=0.1) { + import("./svg/back outline.svg"); + } + + $fn = $preview ? 4 : 8; + if (beveled_edges) { + // Abgeschrägte Kanten. + cylinder(h=4, r1=1.5, r2=0); + } else { + // Abgerundete Kanten. + // Dafür generieren wir im folgenden einen konkaven Kegel. + union() { + curve = [1.34, 1.07, 0.84, 0.63, 0.46, 0.32, 0.2, 0.11, 0.05, 0.01, 0]; + for (i = [0:len(curve)-2]) { + translate([0, 0, i*0.5]) + cylinder(h=0.5, r1=curve[i], r2=curve[i+1]); + } + } + } + } + } + } else { + outer(); + } // Stützen für die Analog sticks. if (stick_support) { diff --git a/front.scad b/front.scad index 06e0aa3..3ea6699 100644 --- a/front.scad +++ b/front.scad @@ -47,10 +47,10 @@ include ; */ // Abgerundete Außenkanten. -rounded_edges = true; +rounded_edges = false; // Abgeschrägte Außenkanten. -beveled_edges = false; +beveled_edges = true; // Aussparungen für den linken Analog-Stick. analog_stick_l = true; @@ -336,26 +336,30 @@ module border_strut(width, length, height) { module casing_front() { difference() { if (rounded_edges || beveled_edges) { - intersection() { + difference() { union () { outer(); } color(color_top) + translate([0, 0, -0.1]) minkowski() { - linear_extrude(height=1) { - import("./svg/front hull.svg"); + linear_extrude(height=0.1) { + import("./svg/front outline.svg"); } - $fn = $preview ? 4 : 16; + + $fn = $preview ? 4 : 8; if (beveled_edges) { // Abgeschrägte Kanten. - cylinder(h=top+space, r1=0.5, r2=(top+space)/2); + cylinder(h=4, r1=1.5, r2=0); } else { // Abgerundete Kanten. - hull() { - for (i = [1:5]) { - translate([0, 0, i - 1]) - cylinder(r=sin(i * (90/5)) * 2, h=top + space); + // Dafür generieren wir im folgenden einen konkaven Kegel. + union() { + curve = [1.34, 1.07, 0.84, 0.63, 0.46, 0.32, 0.2, 0.11, 0.05, 0.01, 0]; + for (i = [0:len(curve)-2]) { + translate([0, 0, i*0.5]) + cylinder(h=0.5, r1=curve[i], r2=curve[i+1]); } } } diff --git a/svg/back hull.svg b/svg/back hull.svg deleted file mode 100644 index a7a2daf..0000000 --- a/svg/back hull.svg +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/svg/back outline.svg b/svg/back outline.svg new file mode 100644 index 0000000..d58d6ea --- /dev/null +++ b/svg/back outline.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + diff --git a/svg/front hull.svg b/svg/front outline.svg similarity index 52% rename from svg/front hull.svg rename to svg/front outline.svg index 3398b8d..2aed9ec 100644 --- a/svg/front hull.svg +++ b/svg/front outline.svg @@ -6,7 +6,7 @@ version="1.1" id="svg8" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" - sodipodi:docname="front hull.svg" + sodipodi:docname="front outline.svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" @@ -23,9 +23,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="2.2345265" - inkscape:cx="283.28149" - inkscape:cy="207.87402" + inkscape:zoom="1.5800489" + inkscape:cx="362.64702" + inkscape:cy="266.13101" inkscape:document-units="mm" inkscape:current-layer="layer1" inkscape:document-rotation="0" @@ -33,23 +33,16 @@ inkscape:showpageshadow="true" inkscape:snap-bbox="true" inkscape:bbox-nodes="true" + inkscape:snap-page="true" inkscape:pagecheckerboard="0" - inkscape:deskcolor="#d1d1d1" - inkscape:window-width="1438" - inkscape:window-height="880" - inkscape:window-x="0" - inkscape:window-y="16" - inkscape:window-maximized="1"> + inkscape:deskcolor="#d1d1d1"> + empspacing="4" /> @@ -59,7 +52,6 @@ image/svg+xml - @@ -68,9 +60,8 @@ inkscape:groupmode="layer" id="layer1"> + id="rect1305" + style="fill:#4d4d4d;stroke:none;stroke-width:4;stroke-linecap:round" + d="M -5.0002116 -5.0002116 L -5.0002116 115.00022 L 154.99984 115.00022 L 154.99984 -5.0002116 L -5.0002116 -5.0002116 z M 9.9999064 0 L 140.00024 0 C 145.54023 3.0946786e-17 150.00015 4.459912 150.00015 9.9999064 L 150.00015 74.000134 C 150.00015 74.750135 149.50021 75.500011 149.00021 76.000012 L 148.00027 76.999951 C 147.50028 77.499971 147.00032 77.999829 147.00033 78.999829 L 147.00033 89.000252 C 147.00041 93.432246 143.4323 96.999659 139.0003 96.999764 L 129.00039 96.999764 C 128.2504 96.999764 127.5 97.500221 127 98.00022 L 126.00006 99.000159 C 125.50006 99.500158 124.75018 100.0001 124.00018 100.0001 L 9.9999064 100.0001 C 4.4599128 100.00013 0 95.540188 0 90.000191 L 0 89.000252 C 0 88.250252 0.49988811 87.499808 0.99993896 86.999858 L 1.9998779 85.999919 C 2.4999775 85.499919 2.9998169 84.75004 2.9998169 84.000041 L 2.9998169 43.999898 C 2.9998158 43.249901 2.4998771 42.500026 1.9998779 42.00002 L 0.99993896 41.000081 C 0.49993876 40.500075 -7.8332324e-17 39.750204 0 39.000203 L 0 9.9999064 C -2.116657e-05 4.459912 4.4599128 -1.2533172e-15 9.9999064 0 z " />