chiark / gitweb /
3499622fbac6ffe79437be978a8fbd5003614d6c
[reprap-play.git] / laptop-sound-cable-hooks.scad
1 // -*- C -*-
2
3 include <utils.scad>
4
5 wall_th = 2;
6 hook_th = 4;
7 hook_hole = 4;
8
9 plug_entry_gap = 1.0;
10
11 plug_l_d = [[ 27.78,
12               10.62 + 0.50 ],
13             [ 40.88,
14               8.56 + 0.50 ],
15             ];
16
17 plug_stem = [ 2.72 + 0.50,
18               5.20 + 0.50 ];
19
20 palmrest_from_plug_z = 3.98;
21 laptop_th = 16.31 + 0.75;
22
23 tongue_len = 50;
24
25 // calculated
26
27 hook_th_plug_holder =
28   plug_l_d[0][1]/2 + wall_th * sin(22.5);
29
30 hook_tongue_h = hook_hole + wall_th*2;
31
32 plug_l_d_smallest = plug_l_d[len(plug_l_d)-1];
33 plug_hook_x_min = -plug_l_d_smallest[0] - wall_th;
34 plug_hook_z_start = -plug_l_d_smallest[1]/2 - wall_th;
35
36 z_laptop_base = palmrest_from_plug_z - laptop_th;
37 z_hook_min = z_laptop_base - hook_tongue_h;
38
39 module PlugMainPlan() {
40   for (l_d = plug_l_d) {
41     l = l_d[0];
42     d = l_d[1];
43     rectfromto([ -l, -d/2 ],
44                [  0, +d/2 ]);
45   }
46 }
47
48 module PlugHolderPlan() {
49   intersection(){
50     hull()
51       offset(r= wall_th)
52       PlugMainPlan();
53
54     rectfromto([-100,-100], [-plug_entry_gap,+100]);
55   }
56 }
57
58 module PlugHookHookPlan(){
59   polygon([ [ plug_hook_x_min, 0 ],
60             [ plug_hook_x_min, plug_hook_z_start ],
61             [ plug_hook_x_min + (plug_hook_z_start - z_hook_min),
62               z_hook_min ],
63             [ -plug_entry_gap, z_hook_min ],
64             [ -plug_entry_gap, 0 ],
65             ]);
66 }
67
68 module TonguePlan(){
69   difference(){
70     rectfromto([ -plug_entry_gap - 1, z_hook_min ],
71                [ tongue_len, z_laptop_base ]);
72     translate([ tongue_len - wall_th - hook_hole/2,
73                 z_hook_min + wall_th + hook_hole/2 ])
74       circle(r = hook_hole/2);
75   }
76 }
77
78 module FarHookPlan(){
79   TonguePlan();
80 }
81
82 module RotateIntersect(n=6){
83   intersection_for (r = [0:n-1]) {
84     rotate([r/n * 360,0,0])
85       linextr(-100,100) children(0);
86   }
87 }
88
89 module PlugHolder(){
90   difference(){
91     union(){
92       RotateIntersect(8)
93         PlugHolderPlan();
94
95       rotate([0,0,180]) {
96         linextr_y_xz(-hook_th_plug_holder/2,
97                      +hook_th_plug_holder/2)
98           PlugHookHookPlan();
99
100         linextr_y_xz(-hook_th/2,
101                      +hook_th/2)
102           TonguePlan();
103       }
104     }
105
106     RotateIntersect(6)
107       PlugMainPlan();
108
109     linextr(-plug_stem[1]/2, 100)
110       rectfromto([ -100, -plug_stem[0]/2 ],
111                  [ +100, +plug_stem[0]/2 ]);
112   }
113 }
114
115 module PlugHolderPrint(){ ////toplevel
116   render() PlugHolder();
117 }
118
119 module DemoPlan() { ////toplevel
120   translate([0,0,-10]) color("grey") PlugHolderPlan();
121   PlugMainPlan();
122   translate([0,0,-5]) color("blue") {
123     PlugHookHookPlan();
124     TonguePlan();
125   }
126
127   translate([0,40,0]) {
128     mirror([1,0,0]) {
129       FarHookPlan();
130     }
131   }
132 }