diff options
author | Tom Short <tshort.rlists@gmail.com> | 2017-03-09 19:25:55 -0500 |
---|---|---|
committer | Tom Short <tshort.rlists@gmail.com> | 2017-03-09 19:25:55 -0500 |
commit | 756bc1450c5237e77be5041a328936b903073518 (patch) | |
tree | 79bb7bec8362cdc6e5bc8765701a872efe58a8b1 | |
parent | ff75080b47dd9c099ffdea1f22a8417c0d13a98d (diff) |
Move ManuForm changes to the main clj
-rw-r--r-- | src/dactyl_keyboard/dactyl.clj | 1329 |
1 files changed, 306 insertions, 1023 deletions
diff --git a/src/dactyl_keyboard/dactyl.clj b/src/dactyl_keyboard/dactyl.clj index f7d2ddd..59cee8b 100644 --- a/src/dactyl_keyboard/dactyl.clj +++ b/src/dactyl_keyboard/dactyl.clj @@ -4,6 +4,18 @@ [scad-clj.model :refer :all] [unicode-math.core :refer :all])) + +(def nrows 6) +(def ncols 6) ; it's not set up to change this +(def lastrow (dec nrows)) +(def cornerrow (dec lastrow)) +(def α (/ π 12)) ; curvature of the columns +(def β (/ π (if (= nrows 4) 26 36))) ; curvature of the rows +(def centerrow (- cornerrow 1)) ; controls front-back tilt +(def centercol 3) ; controls left-right tilt / tenting +(def orthographic-x (> nrows 5)) ; for larger number of rows don't curve them in as much +; (def orthographic-x true) + ;;;;;;;;;;;;;;;;; ;; Switch Hole ;; ;;;;;;;;;;;;;;;;; @@ -86,11 +98,9 @@ ;; Placement Functions ;; ;;;;;;;;;;;;;;;;;;;;;;;;; -(def columns (range 0 6)) -(def rows (range 0 5)) +(def columns (range 0 ncols)) +(def rows (range 0 nrows)) -(def α (/ π 12)) -(def β (/ π 36)) (def cap-top-height (+ plate-thickness sa-profile-key-height)) (def row-radius (+ (/ (/ (+ mount-height 1/2) 2) (Math/sin (/ α 2))) @@ -98,48 +108,40 @@ (def column-radius (+ (/ (/ (+ mount-width 2.0) 2) (Math/sin (/ β 2))) cap-top-height)) +(def column-x-delta (+ -1 (- (* column-radius (Math/sin β))))) (defn key-place [column row shape] (let [row-placed-shape (->> shape (translate [0 0 (- row-radius)]) - (rotate (* α (- 2 row)) [1 0 0]) + (rotate (* α (- centerrow row)) [1 0 0]) (translate [0 0 row-radius])) column-offset (cond (= column 2) [0 2.82 -4.5] (>= column 4) [0 -5.8 5.64] + ; (= column 22) [0 2.82 -4.5] + ; (>= column 24) [0 -5.8 5.64] :else [0 0 0]) - column-angle (* β (- 2 column)) - placed-shape (->> row-placed-shape - (translate [0 0 (- column-radius)]) - (rotate column-angle [0 1 0]) - (translate [0 0 column-radius]) - (translate column-offset))] - (->> placed-shape - (rotate (/ π 12) [0 1 0]) - (translate [0 0 13])))) - -(defn case-place [column row shape] - (let [row-placed-shape (->> shape - (translate [0 0 (- row-radius)]) - (rotate (* α (- 2 row)) [1 0 0]) - (translate [0 0 row-radius])) - column-offset [0 -4.35 5.64] - column-angle (* β (- 2 column)) + column-angle (* β (- centercol column)) placed-shape (->> row-placed-shape (translate [0 0 (- column-radius)]) (rotate column-angle [0 1 0]) (translate [0 0 column-radius]) - (translate column-offset))] - (->> placed-shape + (translate column-offset)) + column-z-delta (* column-radius (- 1 (Math/cos column-angle))) + placed-shape-ortho (->> row-placed-shape + (rotate column-angle [0 1 0]) + (translate [(- (* (- column centercol) column-x-delta)) 0 column-z-delta]) + (translate column-offset))] + (->> (if orthographic-x placed-shape-ortho placed-shape) (rotate (/ π 12) [0 1 0]) - (translate [0 0 13])))) + (translate [0 0 24])))) (def key-holes (apply union (for [column columns row rows - :when (or (not= column 0) - (not= row 4))] + :when (or (.contains [2 3] column) + (not= row lastrow))] (->> single-plate (key-place column row))))) @@ -147,8 +149,8 @@ (apply union (for [column columns row rows - :when (or (not= column 0) - (not= row 4))] + :when (or (.contains [2 3] column) + (not= row lastrow))] (->> (sa-cap (if (= column 5) 1 1)) (key-place column row))))) @@ -177,10 +179,8 @@ (apply union (concat ;; Row connections - (for [column (drop-last columns) - row rows - :when (or (not= column 0) - (not= row 4))] + (for [column (range 0 (dec ncols)) + row (range 0 lastrow)] (triangle-hulls (key-place (inc column) row web-post-tl) (key-place column row web-post-tr) @@ -189,9 +189,7 @@ ;; Column connections (for [column columns - row (drop-last rows) - :when (or (not= column 0) - (not= row 3))] + row (range 0 cornerrow)] (triangle-hulls (key-place column row web-post-bl) (key-place column row web-post-br) @@ -199,10 +197,8 @@ (key-place column (inc row) web-post-tr))) ;; Diagonal connections - (for [column (drop-last columns) - row (drop-last rows) - :when (or (not= column 0) - (not= row 3))] + (for [column (range 0 (dec ncols)) + row (range 0 cornerrow)] (triangle-hulls (key-place column row web-post-br) (key-place column (inc row) web-post-tr) @@ -212,954 +208,287 @@ ;;;;;;;;;;;; ;; Thumbs ;; ;;;;;;;;;;;; +(def thumborigin [-23 -34 47]) + +(defn deg2rad [degrees] + (* (/ degrees 180) pi)) + +(defn thumb-tr-place [shape] + (->> shape + (rotate (deg2rad 10) [1 0 0]) + (rotate (deg2rad -23) [0 1 0]) + (rotate (deg2rad -3) [0 0 1]) + (translate thumborigin) + (translate [-10 -16 0]) + )) +(defn thumb-tl-place [shape] + (->> shape + (rotate (deg2rad 10) [1 0 0]) + (rotate (deg2rad -23) [0 1 0]) + (rotate (deg2rad -3) [0 0 1]) + (translate thumborigin) + (translate [-30 -15 -2]))) +(defn thumb-mr-place [shape] + (->> shape + (rotate (deg2rad -6) [1 0 0]) + (rotate (deg2rad -34) [0 1 0]) + (rotate (deg2rad 48) [0 0 1]) + (translate thumborigin) + (translate [-29 -40 -13]) + )) +(defn thumb-ml-place [shape] + (->> shape + (rotate (deg2rad 6) [1 0 0]) + (rotate (deg2rad -34) [0 1 0]) + (rotate (deg2rad 40) [0 0 1]) + (translate thumborigin) + (translate [-51 -25 -12]))) +(defn thumb-br-place [shape] + (->> shape + (rotate (deg2rad -16) [1 0 0]) + (rotate (deg2rad -33) [0 1 0]) + (rotate (deg2rad 54) [0 0 1]) + (translate thumborigin) + (translate [-37.8 -55.3 -25.3]) + )) +(defn thumb-bl-place [shape] + (->> shape + (rotate (deg2rad -4) [1 0 0]) + (rotate (deg2rad -35) [0 1 0]) + (rotate (deg2rad 52) [0 0 1]) + (translate thumborigin) + (translate [-56.3 -43.3 -23.5]) + )) + +(defn thumb-1x-layout [shape] + (union + (thumb-mr-place shape) + (thumb-ml-place shape) + (thumb-br-place shape) + (thumb-bl-place shape))) -(defn thumb-place [column row shape] - (let [cap-top-height (+ plate-thickness sa-profile-key-height) - α (/ π 12) - row-radius (+ (/ (/ (+ mount-height 1) 2) - (Math/sin (/ α 2))) - cap-top-height) - β (/ π 36) - column-radius (+ (/ (/ (+ mount-width 2) 2) - (Math/sin (/ β 2))) - cap-top-height) - #_(+ (/ (/ (+ pillar-width 5) 2) - (Math/sin (/ β 2))) - cap-top-height)] - (->> shape - (translate [0 0 (- row-radius)]) - (rotate (* α row) [1 0 0]) - (translate [0 0 row-radius]) - (translate [0 0 (- column-radius)]) - (rotate (* column β) [0 1 0]) - (translate [0 0 column-radius]) - (translate [mount-width 0 0]) - (rotate (* π (- 1/4 3/16)) [0 0 1]) - (rotate (/ π 12) [1 1 0]) - (translate [-52 -45 40])))) - -(defn thumb-2x-column [shape] - (thumb-place 0 -1/2 shape)) - -(defn thumb-2x+1-column [shape] - (union (thumb-place 1 -1/2 shape) - (thumb-place 1 1 shape))) - -(defn thumb-1x-column [shape] - (union (thumb-place 2 -1 shape) - (thumb-place 2 0 shape) - (thumb-place 2 1 shape))) - -(defn thumb-layout [shape] +(defn thumb-15x-layout [shape] (union - (thumb-2x-column shape) - (thumb-2x+1-column shape) - (thumb-1x-column shape))) + (thumb-tr-place shape) + (thumb-tl-place shape))) -(def double-plates - (let [plate-height (/ (- sa-double-length mount-height) 2) +(def larger-plate + (let [plate-height (/ (- sa-double-length mount-height) 3) top-plate (->> (cube mount-width plate-height web-thickness) (translate [0 (/ (+ plate-height mount-height) 2) (- plate-thickness (/ web-thickness 2))])) - stabilizer-cutout (union (->> (cube 14.2 3.5 web-thickness) - (translate [0.5 12 (- plate-thickness (/ web-thickness 2))]) - (color [1 0 0 1/2])) - (->> (cube 16 3.5 web-thickness) - (translate [0.5 12 (- plate-thickness (/ web-thickness 2) 1.4)]) - (color [1 0 0 1/2]))) - top-plate (difference top-plate stabilizer-cutout)] + ] (union top-plate (mirror [0 1 0] top-plate)))) (def thumbcaps (union - (thumb-2x-column (sa-cap 2)) - (thumb-place 1 -1/2 (sa-cap 2)) - (thumb-place 1 1 (sa-cap 1)) - (thumb-1x-column (sa-cap 1)))) + (thumb-1x-layout (sa-cap 1)) + (thumb-15x-layout (rotate (/ π 2) [0 0 1] (sa-cap 1.5))))) -(def thumb-connectors - (union - (apply union - (concat - (for [column [2] row [1]] - (triangle-hulls (thumb-place column row web-post-br) - (thumb-place column row web-post-tr) - (thumb-place (dec column) row web-post-bl) - (thumb-place (dec column) row web-post-tl))) - (for [column [2] row [0 1]] - (triangle-hulls - (thumb-place column row web-post-bl) - (thumb-place column row web-post-br) - (thumb-place column (dec row) web-post-tl) - (thumb-place column (dec row) web-post-tr))))) - (let [plate-height (/ (- sa-double-length mount-height) 2) - thumb-tl (->> web-post-tl - (translate [0 plate-height 0])) - thumb-bl (->> web-post-bl - (translate [0 (- plate-height) 0])) - thumb-tr (->> web-post-tr - (translate [0 plate-height 0])) - thumb-br (->> web-post-br - (translate [0 (- plate-height) 0]))] - (union - - ;;Connecting the two doubles - (triangle-hulls (thumb-place 0 -1/2 thumb-tl) - (thumb-place 0 -1/2 thumb-bl) - (thumb-place 1 -1/2 thumb-tr) - (thumb-place 1 -1/2 thumb-br)) - - ;;Connecting the double to the one above it - (triangle-hulls (thumb-place 1 -1/2 thumb-tr) - (thumb-place 1 -1/2 thumb-tl) - (thumb-place 1 1 web-post-br) - (thumb-place 1 1 web-post-bl)) - ;;Connecting the 4 with the double in the bottom left - (triangle-hulls (thumb-place 1 1 web-post-bl) - (thumb-place 1 -1/2 thumb-tl) - (thumb-place 2 1 web-post-br) - (thumb-place 2 0 web-post-tr)) - - ;;Connecting the two singles with the middle double - (hull (thumb-place 1 -1/2 thumb-tl) - (thumb-place 1 -1/2 thumb-bl) - (thumb-place 2 0 web-post-br) - (thumb-place 2 -1 web-post-tr)) - (hull (thumb-place 1 -1/2 thumb-tl) - (thumb-place 2 0 web-post-tr) - (thumb-place 2 0 web-post-br)) - (hull (thumb-place 1 -1/2 thumb-bl) - (thumb-place 2 -1 web-post-tr) - (thumb-place 2 -1 web-post-br)) +(def thumb + (union + (thumb-1x-layout single-plate) + (thumb-15x-layout single-plate) + (thumb-15x-layout larger-plate) + )) - ;;Connecting the thumb to everything - (triangle-hulls (thumb-place 0 -1/2 thumb-br) - (key-place 1 4 web-post-bl) - (thumb-place 0 -1/2 thumb-tr) - (key-place 1 4 web-post-tl) - (key-place 1 3 web-post-bl) - (thumb-place 0 -1/2 thumb-tr) - (key-place 0 3 web-post-br) - (key-place 0 3 web-post-bl) - (thumb-place 0 -1/2 thumb-tr) - (thumb-place 0 -1/2 thumb-tl) - (key-place 0 3 web-post-bl) - (thumb-place 1 -1/2 thumb-tr) - (thumb-place 1 1 web-post-br) - (key-place 0 3 web-post-bl) - (key-place 0 3 web-post-tl) - (thumb-place 1 1 web-post-br) - (thumb-place 1 1 web-post-tr)) - (hull (thumb-place 0 -1/2 web-post-tr) - (thumb-place 0 -1/2 thumb-tr) - (key-place 1 4 web-post-bl) - (key-place 1 4 web-post-tl)))))) +(def thumb-post-tr (translate [(- (/ mount-width 2) post-adj) (- (/ mount-height 1.15) post-adj) 0] web-post)) +(def thumb-post-tl (translate [(+ (/ mount-width -2) post-adj) (- (/ mount-height 1.15) post-adj) 0] web-post)) +(def thumb-post-bl (translate [(+ (/ mount-width -2) post-adj) (+ (/ mount-height -1.15) post-adj) 0] web-post)) +(def thumb-post-br (translate [(- (/ mount-width 2) post-adj) (+ (/ mount-height -1.15) post-adj) 0] web-post)) -(def thumb +(def thumb-connectors (union - thumb-connectors - (thumb-layout (rotate (/ π 2) [0 0 1] single-plate)) - (thumb-place 0 -1/2 double-plates) - (thumb-place 1 -1/2 double-plates))) + (triangle-hulls ; top two + (thumb-tl-place thumb-post-tr) + (thumb-tl-place thumb-post-br) + (thumb-tr-place thumb-post-tl) + (thumb-tr-place thumb-post-bl)) + (triangle-hulls ; bottom two on the right + (thumb-br-place web-post-tr) + (thumb-br-place web-post-br) + (thumb-mr-place web-post-tl) + (thumb-mr-place web-post-bl)) + (triangle-hulls ; bottom two on the left + (thumb-bl-place web-post-tr) + (thumb-bl-place web-post-br) + (thumb-ml-place web-post-tl) + (thumb-ml-place web-post-bl)) + (triangle-hulls ; centers of the bottom four + (thumb-br-place web-post-tl) + (thumb-bl-place web-post-bl) + (thumb-br-place web-post-tr) + (thumb-bl-place web-post-br) + (thumb-mr-place web-post-tl) + (thumb-ml-place web-post-bl) + (thumb-mr-place web-post-tr) + (thumb-ml-place web-post-br)) + (triangle-hulls ; top two to the middle two, starting on the left + (thumb-tl-place thumb-post-tl) + (thumb-ml-place web-post-tr) + (thumb-tl-place thumb-post-bl) + (thumb-ml-place web-post-br) + (thumb-tl-place thumb-post-br) + (thumb-mr-place web-post-tr) + (thumb-tr-place thumb-post-bl) + (thumb-mr-place web-post-br) + (thumb-tr-place thumb-post-br)) + (triangle-hulls ; top two to the main keyboard, starting on the left + (thumb-tl-place thumb-post-tl) + (key-place 0 cornerrow web-post-bl) + (thumb-tl-place thumb-post-tr) + (key-place 0 cornerrow web-post-br) + (thumb-tr-place thumb-post-tl) + (key-place 1 cornerrow web-post-bl) + (thumb-tr-place thumb-post-tr) + (key-place 1 cornerrow web-post-br) + (key-place 2 lastrow web-post-tl) + (key-place 2 lastrow web-post-bl) + (thumb-tr-place thumb-post-tr) + (key-place 2 lastrow web-post-bl) + (thumb-tr-place thumb-post-br) + (key-place 2 lastrow web-post-br) + (key-place 3 lastrow web-post-bl) + (key-place 2 lastrow web-post-tr) + (key-place 3 lastrow web-post-tl) + (key-place 3 cornerrow web-post-bl) + (key-place 3 lastrow web-post-tr) + (key-place 3 cornerrow web-post-br) + (key-place 4 cornerrow web-post-bl)) + (triangle-hulls + (key-place 1 cornerrow web-post-br) + (key-place 2 lastrow web-post-tl) + (key-place 2 cornerrow web-post-bl) + (key-place 2 lastrow web-post-tr) + (key-place 2 cornerrow web-post-br) + (key-place 3 cornerrow web-post-bl) + ) + (triangle-hulls + (key-place 3 lastrow web-post-tr) + (key-place 3 lastrow web-post-br) + (key-place 3 lastrow web-post-tr) + (key-place 4 cornerrow web-post-bl)) + )) ;;;;;;;;;; ;; Case ;; ;;;;;;;;;; -;; In column units -(def right-wall-column (+ (last columns) 0.55)) -(def left-wall-column (- (first columns) 1/2)) -(def thumb-back-y 0.93) -(def thumb-right-wall (- -1/2 0.05)) -(def thumb-front-row (+ -1 0.07)) -(def thumb-left-wall-column (+ 5/2 0.05)) -(def back-y 0.02) - -(defn range-inclusive [start end step] - (concat (range start end step) [end])) - -(def wall-step 0.2) -(def wall-sphere-n 20) ;;Sphere resolution, lower for faster renders - -(defn wall-sphere-at [coords] - (->> (sphere 1) - (translate coords) - (with-fn wall-sphere-n))) - -(defn scale-to-range [start end x] - (+ start (* (- end start) x))) - -(defn wall-sphere-bottom [front-to-back-scale] - (wall-sphere-at [0 - (scale-to-range - (+ (/ mount-height -2) -3.5) - (+ (/ mount-height 2) 5.0) - front-to-back-scale) - -6])) - -(defn wall-sphere-top [front-to-back-scale] - (wall-sphere-at [0 - (scale-to-range - (+ (/ mount-height -2) -3.5) - (+ (/ mount-height 2) 3.5) - front-to-back-scale) - 10])) - -(def wall-sphere-top-back (wall-sphere-top 1)) -(def wall-sphere-bottom-back (wall-sphere-bottom 1)) -(def wall-sphere-bottom-front (wall-sphere-bottom 0)) -(def wall-sphere-top-front (wall-sphere-top 0)) - -(defn top-case-cover [place-fn sphere - x-start x-end - y-start y-end - step] - (apply union - (for [x (range-inclusive x-start (- x-end step) step) - y (range-inclusive y-start (- y-end step) step)] - (hull (place-fn x y sphere) - (place-fn (+ x step) y sphere) - (place-fn x (+ y step) sphere) - (place-fn (+ x step) (+ y step) sphere))))) - -(def front-wall - (let [step wall-step ;;0.1 - wall-step 0.05 ;;0.05 - place case-place - top-cover (fn [x-start x-end y-start y-end] - (top-case-cover place wall-sphere-top-front - x-start x-end y-start y-end - wall-step))] - (union - (apply union - (for [x (range-inclusive 0.7 (- right-wall-column step) step)] - (hull (place x 4 wall-sphere-top-front) - (place (+ x step) 4 wall-sphere-top-front) - (place x 4 wall-sphere-bottom-front) - (place (+ x step) 4 wall-sphere-bottom-front)))) - (apply union - (for [x (range-inclusive 0.5 0.7 0.01)] - (hull (place x 4 wall-sphere-top-front) - (place (+ x step) 4 wall-sphere-top-front) - (place 0.7 4 wall-sphere-bottom-front)))) - (top-cover 0.5 1.7 3.6 4) - (top-cover 1.59 2.41 3.35 4) ;; was 3.32 - (top-cover 2.39 3.41 3.6 4) - (apply union - (for [x (range 2 5)] - (union - (hull (place (- x 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (place (+ x 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place x 4 web-post-bl) - (key-place x 4 web-post-br)) - (hull (place (- x 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place x 4 web-post-bl) - (key-place (- x 1) 4 web-post-br))))) - (hull (place right-wall-column 4 (translate [0 1 1] wall-sphere-bottom-front)) - (place (- right-wall-column 1) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place 5 4 web-post-bl) - (key-place 5 4 web-post-br)) - (hull (place (+ 4 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (place (- right-wall-column 1) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place 4 4 web-post-br) - (key-place 5 4 web-post-bl)) - (hull (place 0.7 4 (translate [0 1 1] wall-sphere-bottom-front)) - (place 1.7 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place 1 4 web-post-bl) - (key-place 1 4 web-post-br))))) - -(def back-wall - (let [step wall-step - wall-sphere-top-backtep 0.05 - place case-place - front-top-cover (fn [x-start x-end y-start y-end] - (apply union - (for [x (range-inclusive x-start (- x-end wall-sphere-top-backtep) wall-sphere-top-backtep) - y (range-inclusive y-start (- y-end wall-sphere-top-backtep) wall-sphere-top-backtep)] - (hull (place x y wall-sphere-top-back) - (place (+ x wall-sphere-top-backtep) y wall-sphere-top-back) - (place x (+ y wall-sphere-top-backtep) wall-sphere-top-back) - (place (+ x wall-sphere-top-backtep) (+ y wall-sphere-top-backtep) wall-sphere-top-back)))))] - (union - (apply union - (for [x (range-inclusive left-wall-column (- right-wall-column step) step)] - (hull (place x back-y wall-sphere-top-back) - (place (+ x step) back-y wall-sphere-top-back) - (place x back-y wall-sphere-bottom-back) - (place (+ x step) back-y wall-sphere-bottom-back)))) - (front-top-cover 1.56 2.44 back-y 0.1) - (front-top-cover 3.56 4.44 back-y 0.13) - (front-top-cover 4.3 right-wall-column back-y 0.13) - - - (hull (place left-wall-column 0 (translate [1 -1 1] wall-sphere-bottom-back)) - (place (+ left-wall-column 1) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (key-place 0 0 web-post-tl) - (key-place 0 0 web-post-tr)) - - (hull (place 5 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (place right-wall-column 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (key-place 5 0 web-post-tl) - (key-place 5 0 web-post-tr)) - - (apply union - (for [x (range 1 5)] - (union - (hull (place (- x 1/2) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (place (+ x 1/2) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (key-place x 0 web-post-tl) - (key-place x 0 web-post-tr)) - (hull (place (- x 1/2) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (key-place x 0 web-post-tl) - (key-place (- x 1) 0 web-post-tr))))) - (hull (place (- 5 1/2) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (place 5 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (key-place 4 0 web-post-tr) - (key-place 5 0 web-post-tl))))) - -(def right-wall - (let [place case-place] - (union - (apply union - (map (partial apply hull) - (partition 2 1 - (for [scale (range-inclusive 0 1 0.01)] - (let [x (scale-to-range 4 0.02 scale)] - (hull (place right-wall-column x (wall-sphere-top scale)) - (place right-wall-column x (wall-sphere-bottom scale)))))))) - - (apply union - (concat - (for [x (range 0 5)] - (union - (hull (place right-wall-column x (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (key-place 5 x web-post-br) - (key-place 5 x web-post-tr)))) - (for [x (range 0 4)] - (union - (hull (place right-wall-column x (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (place right-wall-column (inc x) (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (key-place 5 x web-post-br) - (key-place 5 (inc x) web-post-tr)))) - [(union - (hull (place right-wall-column 0 (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (place right-wall-column 0.02 (translate [-1 -1 1] (wall-sphere-bottom 1))) - (key-place 5 0 web-post-tr)) - (hull (place right-wall-column 4 (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (place right-wall-column 4 (translate [-1 1 1] (wall-sphere-bottom 0))) - (key-place 5 4 web-post-br)))]))))) - -(def left-wall - (let [place case-place] - (union - (apply union - (for [x (range-inclusive -1 (- 1.6666 wall-step) wall-step)] - (hull (place left-wall-column x wall-sphere-top-front) - (place left-wall-column (+ x wall-step) wall-sphere-top-front) - (place left-wall-column x wall-sphere-bottom-front) - (place left-wall-column (+ x wall-step) wall-sphere-bottom-front)))) - (hull (place left-wall-column -1 wall-sphere-top-front) - (place left-wall-column -1 wall-sphere-bottom-front) - (place left-wall-column 0.02 wall-sphere-top-back) - (place left-wall-column 0.02 wall-sphere-bottom-back)) - (hull (place left-wall-column 0 (translate [1 -1 1] wall-sphere-bottom-back)) - (place left-wall-column 1 (translate [1 0 1] wall-sphere-bottom-back)) - (key-place 0 0 web-post-tl) - (key-place 0 0 web-post-bl)) - (hull (place left-wall-column 1 (translate [1 0 1] wall-sphere-bottom-back)) - (place left-wall-column 2 (translate [1 0 1] wall-sphere-bottom-back)) - (key-place 0 0 web-post-bl) - (key-place 0 1 web-post-bl)) - (hull (place left-wall-column 2 (translate [1 0 1] wall-sphere-bottom-back)) - (place left-wall-column 1.6666 (translate [1 0 1] wall-sphere-bottom-front)) - (key-place 0 1 web-post-bl) - (key-place 0 2 web-post-bl)) - (hull (place left-wall-column 1.6666 (translate [1 0 1] wall-sphere-bottom-front)) - (key-place 0 2 web-post-bl) - (key-place 0 3 web-post-tl)) - (hull (place left-wall-column 1.6666 (translate [1 0 1] wall-sphere-bottom-front)) - (thumb-place 1 1 web-post-tr) - (key-place 0 3 web-post-tl)) - (hull (place left-wall-column 1.6666 (translate [1 0 1] wall-sphere-bottom-front)) - (thumb-place 1 1 web-post-tr) - (thumb-place 1/2 thumb-back-y (translate [0 -1 1] wall-sphere-bottom-back)))))) - -(def thumb-back-wall - (let [step wall-step - top-step 0.05 - front-top-cover (fn [x-start x-end y-start y-end] - (apply union - (for [x (range-inclusive x-start (- x-end top-step) top-step) - y (range-inclusive y-start (- y-end top-step) top-step)] - (hull (thumb-place x y wall-sphere-top-back) - (thumb-place (+ x top-step) y wall-sphere-top-back) - (thumb-place x (+ y top-step) wall-sphere-top-back) - (thumb-place (+ x top-step) (+ y top-step) wall-sphere-top-back))))) - back-y thumb-back-y] - (union - (apply union - (for [x (range-inclusive 1/2 (- (+ 5/2 0.05) step) step)] - (hull (thumb-place x back-y wall-sphere-top-back) - (thumb-place (+ x step) back-y wall-sphere-top-back) - (thumb-place x back-y wall-sphere-bottom-back) - (thumb-place (+ x step) back-y wall-sphere-bottom-back)))) - (hull (thumb-place 1/2 back-y wall-sphere-top-back) - (thumb-place 1/2 back-y wall-sphere-bottom-back) - (case-place left-wall-column 1.6666 wall-sphere-top-front)) - (hull (thumb-place 1/2 back-y wall-sphere-bottom-back) - (case-place left-wall-column 1.6666 wall-sphere-top-front) - (case-place left-wall-column 1.6666 wall-sphere-bottom-front)) - (hull - (thumb-place 1/2 thumb-back-y (translate [0 -1 1] wall-sphere-bottom-back)) - (thumb-place 1 1 web-post-tr) - (thumb-place 3/2 thumb-back-y (translate [0 -1 1] wall-sphere-bottom-back)) - (thumb-place 1 1 web-post-tl)) - (hull - (thumb-place (+ 5/2 0.05) thumb-back-y (translate [1 -1 1] wall-sphere-bottom-back)) - (thumb-place 3/2 thumb-back-y (translate [0 -1 1] wall-sphere-bottom-back)) - (thumb-place 1 1 web-post-tl) - (thumb-place 2 1 web-post-tl))))) - -(def thumb-left-wall - (let [step wall-step - place thumb-place] - (union - (apply union - (for [x (range-inclusive (+ -1 0.07) (- 1.95 step) step)] - (hull (place thumb-left-wall-column x wall-sphere-top-front) - (place thumb-left-wall-column (+ x step) wall-sphere-top-front) - (place thumb-left-wall-column x wall-sphere-bottom-front) - (place thumb-left-wall-column (+ x step) wall-sphere-bottom-front)))) - (hull (place thumb-left-wall-column 1.95 wall-sphere-top-front) - (place thumb-left-wall-column 1.95 wall-sphere-bottom-front) - (place thumb-left-wall-column thumb-back-y wall-sphere-top-back) - (place thumb-left-wall-column thumb-back-y wall-sphere-bottom-back)) - - (hull - (thumb-place thumb-left-wall-column thumb-back-y (translate [1 -1 1] wall-sphere-bottom-back)) - (thumb-place thumb-left-wall-column 0 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place 2 1 web-post-tl) - (thumb-place 2 1 web-post-bl)) - (hull - (thumb-place thumb-left-wall-column 0 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place 2 0 web-post-tl) - (thumb-place 2 1 web-post-bl)) - (hull - (thumb-place thumb-left-wall-column 0 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place thumb-left-wall-column -1 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place 2 0 web-post-tl) - (thumb-place 2 0 web-post-bl)) - (hull - (thumb-place thumb-left-wall-column -1 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place 2 -1 web-post-tl) - (thumb-place 2 0 web-post-bl)) - (hull - (thumb-place thumb-left-wall-column -1 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place thumb-left-wall-column (+ -1 0.07) (translate [1 1 1] wall-sphere-bottom-front)) - (thumb-place 2 -1 web-post-tl) - (thumb-place 2 -1 web-post-bl))))) - -(def thumb-front-wall - (let [step wall-step ;;0.1 - wall-sphere-top-fronttep 0.05 ;;0.05 - place thumb-place - plate-height (/ (- sa-double-length mount-height) 2) - thumb-tl (->> web-post-tl - (translate [0 plate-height 0])) - thumb-bl (->> web-post-bl - (translate [0 (- plate-height) 0])) - thumb-tr (->> web-post-tr - (translate [-0 plate-height 0])) - thumb-br (->> web-post-br - (translate [-0 (- plate-height) 0]))] - (union - (apply union - (for [x (range-inclusive thumb-right-wall (- (+ 5/2 0.05) step) step)] - (hull (place x thumb-front-row wall-sphere-top-front) - (place (+ x step) thumb-front-row wall-sphere-top-front) - (place x thumb-front-row wall-sphere-bottom-front) - (place (+ x step) thumb-front-row wall-sphere-bottom-front)))) - - (hull (place thumb-right-wall thumb-front-row wall-sphere-top-front) - (place thumb-right-wall thumb-front-row wall-sphere-bottom-front) - (case-place 0.5 4 wall-sphere-top-front)) - (hull (place thumb-right-wall thumb-front-row wall-sphere-bottom-front) - (case-place 0.5 4 wall-sphere-top-front) - (case-place 0.7 4 wall-sphere-bottom-front)) - - (hull (place thumb-right-wall thumb-front-row wall-sphere-bottom-front) - (key-place 1 4 web-post-bl) - (place 0 -1/2 thumb-br) - (place 0 -1/2 web-post-br) - (case-place 0.7 4 wall-sphere-bottom-front)) - - (hull (place (+ 5/2 0.05) thumb-front-row (translate [1 1 1] wall-sphere-bottom-front)) - (place (+ 3/2 0.05) thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (place 2 -1 web-post-bl) - (place 2 -1 web-post-br)) - - (hull (place thumb-right-wall thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (place (+ 1/2 0.05) thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (place 0 -1/2 thumb-bl) - (place 0 -1/2 thumb-br)) - (hull (place (+ 1/2 0.05) thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (place (+ 3/2 0.05) thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (place 0 -1/2 thumb-bl) - (place 1 -1/2 thumb-bl) - (place 1 -1/2 thumb-br) - (place 2 -1 web-post-br))))) - -(def new-case - (union front-wall - right-wall - back-wall - left-wall - thumb-back-wall - thumb-left-wall - thumb-front-wall)) - -;;;;;;;;;;;; -;; Bottom ;; -;;;;;;;;;;;; - - (defn bottom [height p] (->> (project p) (extrude-linear {:height height :twist 0 :convexity 0}) (translate [0 0 (/ height 2)]))) -(defn bottom-hull [p] - (hull p (bottom 1 p))) +(defn bottom-hull [& p] + (hull p (bottom 10.001 p))) - -(def bottom-key-guard (->> (cube mount-width mount-height web-thickness) - (translate [0 0 (+ (- (/ web-thickness 2)) -4.5)]))) -(def bottom-front-key-guard (->> (cube mount-width (/ mount-height 2) web-thickness) - (translate [0 (/ mount-height 4) (+ (- (/ web-thickness 2)) -4.5)]))) - -(def bottom-plate +(defn wall-brace [place1 dx1 dy1 post1 place2 dx2 dy2 post2] (union - (apply union - (for [column columns - row (drop-last rows) ;; - :when (or (not= column 0) - (not= row 4))] - (->> bottom-key-guard - (key-place column row)))) - (thumb-layout (rotate (/ π 2) [0 0 1] bottom-key-guard)) - (apply union - (for [column columns - row [(last rows)] ;; - :when (or (not= column 0) - (not= row 4))] - (->> bottom-front-key-guard - (key-place column row)))) - (let [shift #(translate [0 0 (+ (- web-thickness) -5)] %) - web-post-tl (shift web-post-tl) - web-post-tr (shift web-post-tr) - web-post-br (shift web-post-br) - web-post-bl (shift web-post-bl) - half-shift-correction #(translate [0 (/ mount-height 2) 0] %) - half-post-br (half-shift-correction web-post-br) - half-post-bl (half-shift-correction web-post-bl) - row-connections (concat - (for [column (drop-last columns) - row (drop-last rows) - :when (or (not= column 0) - (not= row 4))] - (triangle-hulls - (key-place (inc column) row web-post-tl) - (key-place column row web-post-tr) - (key-place (inc column) row web-post-bl) - (key-place column row web-post-br))) - (for [column (drop-last columns) - row [(last rows)] - :when (or (not= column 0) - (not= row 4))] - (triangle-hulls - (key-place (inc column) row web-post-tl) - (key-place column row web-post-tr) - (key-place (inc column) row half-post-bl) - (key-place column row half-post-br)))) - column-connections (for [column columns - row (drop-last rows) - :when (or (not= column 0) - (not= row 3))] - (triangle-hulls - (key-place column row web-post-bl) - (key-place column row web-post-br) - (key-place column (inc row) web-post-tl) - (key-place column (inc row) web-post-tr))) - diagonal-connections (for [column (drop-last columns) - row (drop-last rows) - :when (or (not= column 0) - (not= row 3))] - (triangle-hulls - (key-place column row web-post-br) - (key-place column (inc row) web-post-tr) - (key-place (inc column) row web-post-bl) - (key-place (inc column) (inc row) web-post-tl))) - main-keys-bottom (concat row-connections - column-connections - diagonal-connections) - front-wall (concat - (for [x (range 2 5)] - (union - (hull (case-place (- x 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (case-place (+ x 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place x 4 half-post-bl) - (key-place x 4 half-post-br)) - (hull (case-place (- x 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place x 4 half-post-bl) - (key-place (- x 1) 4 half-post-br)))) - [(hull (case-place right-wall-column 4 (translate [0 1 1] wall-sphere-bottom-front)) - (case-place (- right-wall-column 1) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place 5 4 half-post-bl) - (key-place 5 4 half-post-br)) - (hull (case-place (+ 4 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (case-place (- right-wall-column 1) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (key-place 4 4 half-post-br) - (key-place 5 4 half-post-bl))]) - right-wall (concat - (for [x (range 0 4)] - (hull (case-place right-wall-column x (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (key-place 5 x web-post-br) - (key-place 5 x web-post-tr))) - (for [x (range 0 4)] - (hull (case-place right-wall-column x (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (case-place right-wall-column (inc x) (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (key-place 5 x web-post-br) - (key-place 5 (inc x) web-post-tr))) - [(union - (hull (case-place right-wall-column 0 (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (case-place right-wall-column 0.02 (translate [-1 -1 1] (wall-sphere-bottom 1))) - (key-place 5 0 web-post-tr) - ) - (hull (case-place right-wall-column 4 (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (case-place right-wall-column 4 (translate [0 1 1] (wall-sphere-bottom 0))) - (key-place 5 4 half-post-br) - ) - (hull (case-place right-wall-column 4 (translate [-1 0 1] (wall-sphere-bottom 1/2))) - (key-place 5 4 half-post-br) - (key-place 5 4 web-post-tr)))]) - back-wall (concat - (for [x (range 1 6)] - (union - (hull (case-place (- x 1/2) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (case-place (+ x 1/2) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (key-place x 0 web-post-tl) - (key-place x 0 web-post-tr)) - (hull (case-place (- x 1/2) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (key-place x 0 web-post-tl) - (key-place (- x 1) 0 web-post-tr)))) - [(hull (case-place left-wall-column 0 (translate [1 -1 1] wall-sphere-bottom-back)) - (case-place (+ left-wall-column 1) 0 (translate [0 -1 1] wall-sphere-bottom-back)) - (key-place 0 0 web-post-tl) - (key-place 0 0 web-post-tr))]) - left-wall (let [place case-place] - [(hull (place left-wall-column 0 (translate [1 -1 1] wall-sphere-bottom-back)) - (place left-wall-column 1 (translate [1 0 1] wall-sphere-bottom-back)) - (key-place 0 0 web-post-tl) - (key-place 0 0 web-post-bl)) - (hull (place left-wall-column 1 (translate [1 0 1] wall-sphere-bottom-back)) - (place left-wall-column 2 (translate [1 0 1] wall-sphere-bottom-back)) - (key-place 0 0 web-post-bl) - (key-place 0 1 web-post-bl)) - (hull (place left-wall-column 2 (translate [1 0 1] wall-sphere-bottom-back)) - (place left-wall-column 1.6666 (translate [1 0 1] wall-sphere-bottom-front)) - (key-place 0 1 web-post-bl) - (key-place 0 2 web-post-bl)) - (hull (place left-wall-column 1.6666 (translate [1 0 1] wall-sphere-bottom-front)) - (key-place 0 2 web-post-bl) - (key-place 0 3 web-post-tl))]) - thumbs [(hull (thumb-place 0 -1/2 web-post-bl) - (thumb-place 0 -1/2 web-post-tl) - (thumb-place 1 -1/2 web-post-tr) - (thumb-place 1 -1/2 web-post-br)) - (hull (thumb-place 1 -1/2 web-post-tr) - (thumb-place 1 -1/2 web-post-tl) - (thumb-place 1 1 web-post-bl) - (thumb-place 1 1 web-post-br)) - (hull (thumb-place 2 -1 web-post-tr) - (thumb-place 2 -1 web-post-tl) - (thumb-place 2 0 web-post-bl) - (thumb-place 2 0 web-post-br)) - (hull (thumb-place 2 0 web-post-tr) - (thumb-place 2 0 web-post-tl) - (thumb-place 2 1 web-post-bl) - (thumb-place 2 1 web-post-br)) - (triangle-hulls (thumb-place 2 1 web-post-tr) - (thumb-place 1 1 web-post-tl) - (thumb-place 2 1 web-post-br) - (thumb-place 1 1 web-post-bl) - (thumb-place 2 0 web-post-tr) - (thumb-place 1 -1/2 web-post-tl) - (thumb-place 2 0 web-post-br) - (thumb-place 1 -1/2 web-post-bl) - (thumb-place 2 -1 web-post-tr) - (thumb-place 2 -1 web-post-br)) - (hull (thumb-place 2 -1 web-post-br) - (thumb-place 1 -1/2 web-post-bl) - (thumb-place 1 -1 web-post-bl)) - (hull (thumb-place 1 -1/2 web-post-bl) - (thumb-place 1 -1 web-post-bl) - (thumb-place 1 -1/2 web-post-br) - (thumb-place 1 -1 web-post-br)) - (hull (thumb-place 0 -1/2 web-post-bl) - (thumb-place 0 -1 web-post-bl) - (thumb-place 0 -1/2 web-post-br) - (thumb-place 0 -1 web-post-br)) - (hull (thumb-place 0 -1/2 web-post-bl) - (thumb-place 0 -1 web-post-bl) - (thumb-place 1 -1/2 web-post-br) - (thumb-place 1 -1 web-post-br))] - thumb-back-wall [(hull - (thumb-place 1/2 thumb-back-y (translate [0 -1 1] wall-sphere-bottom-back)) - (thumb-place 1 1 web-post-tr) - (thumb-place 3/2 thumb-back-y (translate [0 -1 1] wall-sphere-bottom-back)) - (thumb-place 1 1 web-post-tl)) - - (hull - (thumb-place (+ 5/2 0.05) thumb-back-y (translate [1 -1 1] wall-sphere-bottom-back)) - (thumb-place 3/2 thumb-back-y (translate [0 -1 1] wall-sphere-bottom-back)) - (thumb-place 1 1 web-post-tl) - (thumb-place 2 1 web-post-tl)) - (hull - (thumb-place 1/2 thumb-back-y (translate [0 -1 1] wall-sphere-bottom-back)) - (case-place left-wall-column 1.6666 (translate [1 0 1] wall-sphere-bottom-front)) - (key-place 0 3 web-post-tl) - (thumb-place 1 1 web-post-tr)) - ] - thumb-left-wall [(hull - (thumb-place thumb-left-wall-column thumb-back-y (translate [1 -1 1] wall-sphere-bottom-back)) - (thumb-place thumb-left-wall-column 0 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place 2 1 web-post-tl) - (thumb-place 2 1 web-post-bl)) - (hull - (thumb-place thumb-left-wall-column 0 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place 2 0 web-post-tl) - (thumb-place 2 1 web-post-bl)) - (hull - (thumb-place thumb-left-wall-column 0 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place thumb-left-wall-column -1 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place 2 0 web-post-tl) - (thumb-place 2 0 web-post-bl)) - (hull - (thumb-place thumb-left-wall-column -1 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place 2 -1 web-post-tl) - (thumb-place 2 0 web-post-bl)) - (hull - (thumb-place thumb-left-wall-column -1 (translate [1 0 1] wall-sphere-bottom-back)) - (thumb-place thumb-left-wall-column (+ -1 0.07) (translate [1 1 1] wall-sphere-bottom-front)) - (thumb-place 2 -1 web-post-tl) - (thumb-place 2 -1 web-post-bl))] - thumb-front-wall [(hull (thumb-place (+ 5/2 0.05) thumb-front-row (translate [1 1 1] wall-sphere-bottom-front)) - (thumb-place (+ 3/2 0.05) thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (thumb-place 2 -1 web-post-bl) - (thumb-place 2 -1 web-post-br)) - (hull (thumb-place (+ 1/2 0.05) thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (thumb-place (+ 3/2 0.05) thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (thumb-place 0 -1 web-post-bl) - (thumb-place 1 -1 web-post-bl) - (thumb-place 1 -1 web-post-br) - (thumb-place 2 -1 web-post-br)) - (hull (thumb-place thumb-right-wall thumb-front-row (translate [-1 1 1] wall-sphere-bottom-front)) - (thumb-place (+ 1/2 0.05) thumb-front-row (translate [0 1 1] wall-sphere-bottom-front)) - (thumb-place 0 -1 web-post-bl) - (thumb-place 0 -1 web-post-br))] - thumb-inside [(triangle-hulls - (thumb-place 1 1 web-post-tr) - (key-place 0 3 web-post-tl) - (thumb-place 1 1 web-post-br) - (key-place 0 3 web-post-bl) - (thumb-place 1 -1/2 web-post-tr) - (thumb-place 0 -1/2 web-post-tl) - (key-place 0 3 web-post-bl) - (thumb-place 0 -1/2 web-post-tr) - (key-place 0 3 web-post-br) - (key-place 1 3 web-post-bl) - (thumb-place 0 -1/2 web-post-tr) - (key-place 1 4 web-post-tl) - (key-place 1 4 half-post-bl)) - - (hull - (thumb-place 0 -1/2 web-post-tr) - (thumb-place 0 -1/2 web-post-br) - (key-place 1 4 half-post-bl)) - - (hull - (key-place 1 4 half-post-bl) - (key-place 1 4 half-post-br) - (case-place (- 2 1/2) 4 (translate [0 1 1] wall-sphere-bottom-front)) - (case-place 0.7 4 (translate [0 1 1] wall-sphere-bottom-front))) - - (hull - (thumb-place 0 -1 web-post-br) - (thumb-place 0 -1/2 web-post-br) - (thumb-place thumb-right-wall thumb-front-row (translate [-1 1 1] wall-sphere-bottom-front)) - (key-place 1 4 (translate [0 0 8.5] web-post-bl)) - (key-place 1 4 half-post-bl) - )] - stands (let [bumper-diameter 9.6 - bumper-radius (/ bumper-diameter 2) - stand-diameter (+ bumper-diameter 2) - stand-radius (/ stand-diameter 2) - stand-at #(difference (->> (sphere stand-radius) - (translate [0 0 (+ (/ stand-radius -2) -4.5)]) - % - (bottom-hull)) - (->> (cube stand-diameter stand-diameter stand-radius) - (translate [0 0 (/ stand-radius -2)]) - %) - (->> (sphere bumper-radius) - (translate [0 0 (+ (/ stand-radius -2) -4.5)]) - % - (bottom 1.5)))] - [(stand-at #(key-place 0 1 %)) - (stand-at #(thumb-place 1 -1/2 %)) - (stand-at #(key-place 5 0 %)) - (stand-at #(key-place 5 3 %))])] - (apply union - (concat - main-keys-bottom - front-wall - right-wall - back-wall - left-wall - thumbs - thumb-back-wall - thumb-left-wall - thumb-front-wall - thumb-inside - stands))))) - -(def screw-hole (->> (cylinder 1.5 60) - (translate [0 0 3/2]) - (with-fn wall-sphere-n))) - -(def screw-holes + (hull + (place1 post1) + (place1 (translate [0 0 -15] post1)) + (place1 (translate [(* dx1 5) (* dy1 5) -4] post1)) + (place1 (translate [(* dx1 5) (* dy1 5) -15] post1)) + (place2 post2) + (place2 (translate [0 0 -15] post2)) + (place2 (translate [(* dx2 5) (* dy2 5) -4] post2)) + (place2 (translate [(* dx2 5) (* dy2 5) -15] post2))) + (bottom-hull + (place1 (translate [(* dx1 5) (* dy1 5) -15] post1)) + (place1 (translate [0 0 -15] post1)) + (place1 (translate [(* dx1 5) (* dy1 5) -15] post1)) + (place2 (translate [0 0 -15] post2)) + (place2 (translate [(* dx2 5) (* dy2 5) -15] post2))))) + +(defn key-wall-brace [x1 y1 dx1 dy1 post1 x2 y2 dx2 dy2 post2] + (wall-brace (partial key-place x1 y1) dx1 dy1 post1 + (partial key-place x2 y2) dx2 dy2 post2)) + +(def case-walls (union - (key-place (+ 4 1/2) 1/2 screw-hole) - (key-place (+ 4 1/2) (+ 3 1/2) screw-hole) - (thumb-place 2 -1/2 screw-hole))) - -(defn circuit-cover [width length height] - (let [cover-sphere-radius 1 - cover-sphere (->> (sphere cover-sphere-radius) - (with-fn 20)) - cover-sphere-z (+ (- height) (- cover-sphere-radius)) - cover-sphere-x (+ (/ width 2) cover-sphere-radius) - cover-sphere-y (+ (/ length 2) (+ cover-sphere-radius)) - cover-sphere-tl (->> cover-sphere - (translate [(- cover-sphere-x) (- cover-sphere-y) cover-sphere-z]) - (key-place 1/2 3/2)) - cover-sphere-tr (->> cover-sphere - (translate [cover-sphere-x (- cover-sphere-y) cover-sphere-z]) - (key-place 1/2 3/2)) - cover-sphere-br (->> cover-sphere - (translate [cover-sphere-x cover-sphere-y cover-sphere-z]) - (key-place 1/2 3/2)) - cover-sphere-bl (->> cover-sphere - (translate [(- cover-sphere-x) cover-sphere-y cover-sphere-z]) - (key-place 1/2 3/2)) - - lower-to-bottom #(translate [0 0 (+ (- cover-sphere-radius) -5.5)] %) - bl (->> cover-sphere lower-to-bottom (key-place 0 1/2)) - br (->> cover-sphere lower-to-bottom (key-place 1 1/2)) - tl (->> cover-sphere lower-to-bottom (key-place 0 5/2)) - tr (->> cover-sphere lower-to-bottom (key-place 1 5/2)) - - mlb (->> cover-sphere - (translate [(- cover-sphere-x) 0 (+ (- height) -1)]) - (key-place 1/2 3/2)) - mrb (->> cover-sphere - (translate [cover-sphere-x 0 (+ (- height) -1)]) - (key-place 1/2 3/2)) - - mlt (->> cover-sphere - (translate [(+ (- cover-sphere-x) -4) 0 -6]) - (key-place 1/2 3/2)) - mrt (->> cover-sphere - (translate [(+ cover-sphere-x 4) 0 -6]) - (key-place 1/2 3/2))] - (union - (hull cover-sphere-bl cover-sphere-br cover-sphere-tl cover-sphere-tr) - (hull cover-sphere-br cover-sphere-bl bl br) - (hull cover-sphere-tr cover-sphere-tl tl tr) - (hull cover-sphere-tl tl mlb mlt) - (hull cover-sphere-bl bl mlb mlt) - (hull cover-sphere-tr tr mrb mrt) - (hull cover-sphere-br br mrb mrt)))) - -(def io-exp-width 10) -(def io-exp-height 8) -(def io-exp-length 36) - -(def teensy-width 20) + ; back wall + (for [x (range 0 6)] (key-wall-brace x 0 0 1 web-post-tl x 0 0 1 web-post-tr)) + (for [x (range 1 6)] (key-wall-brace x 0 0 1 web-post-tl (dec x) 0 0 1 web-post-tr)) + (key-wall-brace 0 0 0 1 web-post-tl 0 0 -1 0 web-post-tl) + (key-wall-brace 5 0 0 1 web-post-tr 5 0 1 0 web-post-tr) + ; right wall + (for [y (range 0 lastrow)] (key-wall-brace 5 y 1 0 web-post-tr 5 y 1 0 web-post-br)) + (for [y (range 1 lastrow)] (key-wall-brace 5 (dec y) 1 0 web-post-br 5 y 1 0 web-post-tr)) + (key-wall-brace 5 cornerrow 0 -1 web-post-br 5 cornerrow 1 0 web-post-br) + ; left wall + (for [y (range 0 lastrow)] (key-wall-brace 0 y -1 0 web-post-tl 0 y -1 0 web-post-bl)) + (for [y (range 1 lastrow)] (key-wall-brace 0 (dec y) -1 0 web-post-bl 0 y -1 0 web-post-tl)) + ; front wall + (key-wall-brace 3 lastrow 0 -1 web-post-bl 3 lastrow 0.5 -1 web-post-br) + (key-wall-brace 4 cornerrow 0 -1 web-post-bl 4 cornerrow 0 -1 web-post-br) + (key-wall-brace 5 cornerrow 0 -1 web-post-bl 5 cornerrow 0 -1 web-post-br) + (key-wall-brace 3 lastrow 0.5 -1 web-post-br 4 cornerrow 1 -1 web-post-bl) + (key-wall-brace 4 cornerrow 0 -1 web-post-br 5 cornerrow 0 -1 web-post-bl) + ; thumb walls + (wall-brace thumb-mr-place 0 -1 web-post-br thumb-tr-place 0 -1 thumb-post-br) + (wall-brace thumb-mr-place 0 -1 web-post-br thumb-mr-place 0 -1 web-post-bl) + (wall-brace thumb-br-place 0 -1 web-post-br thumb-br-place 0 -1 web-post-bl) + (wall-brace thumb-ml-place 0 1 web-post-tr thumb-ml-place 0 1 web-post-tl) + (wall-brace thumb-bl-place 0 1 web-post-tr thumb-bl-place 0 1 web-post-tl) + (wall-brace thumb-br-place -1 0 web-post-tl thumb-br-place -1 0 web-post-bl) + (wall-brace thumb-bl-place -1 0 web-post-tl thumb-bl-place -1 0 web-post-bl) + ; thumb corners + (wall-brace thumb-br-place -1 0 web-post-bl thumb-br-place 0 -1 web-post-bl) + (wall-brace thumb-bl-place -1 0 web-post-tl thumb-bl-place 0 1 web-post-tl) + ; thumb tweeners + (wall-brace thumb-mr-place 0 -1 web-post-bl thumb-br-place 0 -1 web-post-br) + (wall-brace thumb-ml-place 0 1 web-post-tl thumb-bl-place 0 1 web-post-tr) + (wall-brace thumb-bl-place -1 0 web-post-bl thumb-br-place -1 0 web-post-tl) + (wall-brace thumb-tr-place 0 -1 thumb-post-br (partial key-place 3 lastrow) 0 -1 web-post-bl) + ; clunky bit on the top left thumb connection + (wall-brace thumb-ml-place 0 1 web-post-tr thumb-tl-place -2.5 0 thumb-post-tl) + (wall-brace thumb-tl-place -1 0 thumb-post-tl (partial key-place 0 cornerrow) -1 0 web-post-bl) + ;; another incomplete try to fix this + ; (bottom-hull (thumb-tl-place thumb-post-tl) + ; (thumb-tl-place (translate [-7 0 0] thumb-post-tl)) + ; (thumb-ml-place web-post-tr) + ; (thumb-ml-place (translate [0 5 -4] web-post-tr))) + )) + +(defn on-wall-place [column depth shape] + (translate [0 0 (- depth)] + (key-place column 0 + (->> shape + (rotate (+ (* β (- centercol column)) (/ π 12)) [0 -1 0]) + (rotate (* α centerrow) [-1 0 0]) + (translate [0 (/ mount-height 2) -15]) + )))) + +(def rj9-cube (cube 14.78 13 22.38)) +(def rj9-space (on-wall-place 1 20 rj9-cube)) +(def rj9-holder (on-wall-place 1 20 + (difference rj9-cube + (union (translate [0 2 0] (cube 10.78 9 18.38)) + (translate [0 0 5] (cube 10.78 13 5)))))) + +(def teensy-width 20) ; was 20 (def teensy-height 12) (def teensy-length 33) - -(def io-exp-cover (circuit-cover io-exp-width io-exp-length io-exp-height)) -(def teensy-cover (circuit-cover teensy-width teensy-length teensy-height)) - -(def trrs-diameter 6.6) -(def trrs-radius (/ trrs-diameter 2)) -(def trrs-hole-depth 10) - -(def trrs-hole (->> (union (cylinder trrs-radius trrs-hole-depth) - (->> (cube trrs-diameter (+ trrs-radius 5) trrs-hole-depth) - (translate [0 (/ (+ trrs-radius 5) 2) 0]))) - (rotate (/ π 2) [1 0 0]) - (translate [0 (+ (/ mount-height 2) 4) (- trrs-radius)]) - (with-fn 50))) - -(def trrs-hole-just-circle - (->> (cylinder trrs-radius trrs-hole-depth) - (rotate (/ π 2) [1 0 0]) - (translate [0 (+ (/ mount-height 2) 4) (- trrs-radius)]) - (with-fn 50) - (key-place 1/2 0))) - -(def trrs-box-hole (->> (cube 14 14 7 ) - (translate [0 1 -3.5]))) - - -(def trrs-cutout - (->> (union trrs-hole - trrs-box-hole) - (key-place 1/2 0))) - -(def teensy-pcb-thickness 1.6) +(def teensy2-length 53) +(def teensy-pcb-thickness 1.6) (def teensy-offset-height 5) -(def teensy-pcb (->> (cube 18 30.5 teensy-pcb-thickness) - (translate [0 0 (+ (/ teensy-pcb-thickness -2) (- teensy-offset-height))]) - (key-place 1/2 3/2) - (color [1 0 0]))) - -(def teensy-support - (difference - (union - (->> (cube 3 3 9) - (translate [0 0 -2]) - (key-place 1/2 3/2) - (color [0 1 0])) - (hull (->> (cube 3 6 9) - (translate [0 0 -2]) - (key-place 1/2 2) - (color [0 0 1])) - (->> (cube 3 3 (+ teensy-pcb-thickness 3)) - (translate [0 (/ 30.5 -2) (+ (- teensy-offset-height) - #_(/ (+ teensy-pcb-thickness 3) -2) - )]) - (key-place 1/2 3/2) - (color [0 0 1])))) - teensy-pcb - (->> (cube 18 30.5 teensy-pcb-thickness) - (translate [0 1.5 (+ (/ teensy-pcb-thickness -2) (- teensy-offset-height) -1)]) - (key-place 1/2 3/2) - (color [1 0 0])))) +(def teensy-holder + (on-wall-place 0 20 + (translate [-5 0 0] + (union + (->> (cube 3 (* 1.2 teensy2-length) (+ 6 teensy-width)) + (translate [-1.5 -30 0])) + (->> (cube teensy-pcb-thickness (* 1.2 teensy2-length) 3) + (translate [(/ teensy-pcb-thickness 2) -30 (- -1.5 (/ teensy-width 2))])) + (->> (cube 4 (* 1.2 teensy2-length) 4) + (translate [(+ 2 teensy-pcb-thickness) -30 (- -1 (/ teensy-width 2))])) + (->> (cube teensy-pcb-thickness (* 0.2 teensy2-length) 3) + (translate [(/ teensy-pcb-thickness 2) (+ (* 0.5 teensy2-length) -30) (+ 1.5 (/ teensy-width 2))])) + (->> (cube 4 (* 0.2 teensy2-length) 4) + (translate [(+ 2 teensy-pcb-thickness) (+ (* 0.5 teensy2-length) -30) (+ 1 (/ teensy-width 2))])) + )))) (def usb-cutout (let [hole-height 6.2 @@ -1171,71 +500,25 @@ (->> (hull side-cylinder (mirror [-1 0 0] side-cylinder)) (rotate (/ π 2) [1 0 0]) - (translate [0 (/ teensy-length 2) (- side-radius)]) - (translate [0 0 (- 1)]) - (translate [0 0 (- teensy-offset-height)]) - (key-place 1/2 3/2)))) - -;;;;;;;;;;;;;;;;;; -;; Final Export ;; -;;;;;;;;;;;;;;;;;; - -(def dactyl-bottom-right - (difference - (union - teensy-cover - (difference - bottom-plate - (hull teensy-cover) - new-case - teensy-cover - trrs-cutout - (->> (cube 1000 1000 10) (translate [0 0 -5])) - screw-holes)) - usb-cutout)) - -(def dactyl-bottom-left - (mirror [-1 0 0] - (union - io-exp-cover - (difference - bottom-plate - (hull io-exp-cover) - new-case - io-exp-cover - trrs-cutout - (->> (cube 1000 1000 10) (translate [0 0 -5])) - screw-holes)))) - -(def dactyl-top-right - (difference - (union key-holes - connectors - thumb - new-case - teensy-support) - trrs-hole-just-circle - screw-holes)) - -(def dactyl-top-left - (mirror [-1 0 0] - (difference - (union key-holes - connectors - thumb - new-case) - trrs-hole-just-circle - screw-holes))) - -(spit "things/dactyl-top-right.scad" - (write-scad dactyl-top-right)) - -(spit "things/dactyl-bottom-right.scad" - (write-scad dactyl-bottom-right)) - -(spit "things/dactyl-top-left.scad" - (write-scad dactyl-top-left)) - -(spit "things/dactyl-bottom-left.scad" - (write-scad dactyl-bottom-left)) + (rotate (/ π 2) [0 1 0]) + (on-wall-place 0 20)))) + +;; teensy info +; base width - 18 +; height - 1.45 +; + +(spit "things/right.scad" + (write-scad (union + key-holes + connectors + thumb + thumb-connectors + (difference case-walls rj9-space usb-cutout) + rj9-holder + (if (= nrows 4) teensy-holder) + ; thumbcaps + ; caps + ))) + |