chiark / gitweb /
laptop-sound-cable-hooks: 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
9 plug_l_d = [[ 27.78,
10               10.62 + 0.50 ],
11             [ 40.88,
12               8.56 + 0.50 ],
13             ];
14
15 plug_stem = [ 2.72 + 0.50,
16               5.20 + 0.50 ];
17
18 palmrest_from_plug_z = 3.98;
19 laptop_th = 16.31 + 0.75;
20
21 tongue_len = 50;
22
23 // calculated
24
25 hook_th_plug_holder =
26   plug_l_d[0][1]/2 + wall_th * sin(22.5);
27
28 hook_tongue_h = hook_hole + wall_th*2;
29
30 plug_l_d_smallest = plug_l_d[len(plug_l_d)-1];
31 plug_hook_x_min = -plug_l_d_smallest[0] - wall_th;
32 plug_hook_z_start = -plug_l_d_smallest[1]/2 - wall_th;
33
34 plug_hook_z_laptop_base = palmrest_from_plug_z - laptop_th;
35 plug_hook_z_min = plug_hook_z_laptop_base - hook_tongue_h;
36
37 module PlugMainPlan() {
38   for (l_d = plug_l_d) {
39     l = l_d[0];
40     d = l_d[1];
41     rectfromto([ -l, -d/2 ],
42                [  0, +d/2 ]);
43   }
44 }
45
46 module PlugHolderPlan() {
47   intersection(){
48     hull()
49       offset(r= wall_th)
50       PlugMainPlan();
51
52     rectfromto([-100,-100], [-0.1,+100]);
53   }
54 }
55
56 module PlugHookHookPlan(){
57   polygon([ [ plug_hook_x_min, 0 ],
58             [ plug_hook_x_min, plug_hook_z_start ],
59             [ plug_hook_x_min + (plug_hook_z_start - plug_hook_z_min),
60               plug_hook_z_min ],
61             [ 0, plug_hook_z_min ],
62             [ 0, 0 ],
63             ]);
64 }
65
66 module PlugHookTonguePlan(){
67   rectfromto([ -1, plug_hook_z_min ],
68              [ tongue_len, plug_hook_z_laptop_base ]);
69 }
70
71 module RotateIntersect(n=6){
72   intersection_for (r = [0:n-1]) {
73     rotate([r/n * 360,0,0])
74       linextr(-100,100) children(0);
75   }
76 }
77
78 module PlugHolder(){
79   difference(){
80     union(){
81       RotateIntersect(8)
82         PlugHolderPlan();
83
84       rotate([0,0,180]) {
85         linextr_y_xz(-hook_th_plug_holder/2,
86                      +hook_th_plug_holder/2)
87           PlugHookHookPlan();
88
89         linextr_y_xz(-hook_th/2,
90                      +hook_th/2)
91           PlugHookTonguePlan();
92       }
93     }
94
95     RotateIntersect(6)
96       PlugMainPlan();
97
98     linextr(-plug_stem[1]/2, 100)
99       rectfromto([ -100, -plug_stem[0]/2 ],
100                  [ +100, +plug_stem[0]/2 ]);
101   }
102 }
103
104 module DemoPlan() {
105   translate([0,0,-5]) color("grey") PlugHolderPlan();
106   PlugMainPlan();
107 }
108
109 //DemoPlan();
110 //PlugHookHookPlan();
111 render() PlugHolder();