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             [ tongue_len, plug_hook_z_min ],
62             [ tongue_len, plug_hook_z_laptop_base ],
63             [ 0, plug_hook_z_laptop_base ],
64             [ 0, 0 ],
65             ]);
66 }
67
68 module RotateIntersect(n=6){
69   intersection_for (r = [0:n-1]) {
70     rotate([r/n * 360,0,0])
71       linextr(-100,100) children(0);
72   }
73 }
74
75 module PlugHolder(){
76   difference(){
77     union(){
78       RotateIntersect(8)
79         PlugHolderPlan();
80
81       rotate([0,0,180])
82         linextr_y_xz(-hook_th_plug_holder,
83                      +hook_th_plug_holder)
84         PlugHookHookPlan();
85     }
86
87     RotateIntersect(6)
88       PlugMainPlan();
89
90     linextr(-plug_stem[1]/2, 100)
91       rectfromto([ -100, -plug_stem[0]/2 ],
92                  [ +100, +plug_stem[0]/2 ]);
93   }
94 }
95
96 module DemoPlan() {
97   translate([0,0,-5]) color("grey") PlugHolderPlan();
98   PlugMainPlan();
99 }
100
101 //DemoPlan();
102 //PlugHookHookPlan();
103 render() PlugHolder();