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