chiark / gitweb /
bce69402a73deaeebf1ffe2817c83dab89a4223a
[reprap-play.git] / crossbar-computer-led-mount.scad
1 // -*- C -*-
2
3 led_dia = 5 + 0.6;
4 led_depth = 5;
5
6 led_tip_z = 70;
7 led_angle = -60;
8
9 vert_space_inside = 8;
10 backfront_space_inside = 12;
11
12 backfront_mate_size = 25;
13 tower_frontheight = 20;
14 tower_width = 18;
15 tower_slot_width = 3;
16
17 // tuning
18
19 tower_over_angle = 45;
20 tower_wall_thick = 1.6;
21 tower_base_height = 10;
22 tower_forehead_angle = 30;
23
24 //--- tests ---
25
26 test_width = 24;
27 test_height = 24;
28
29 test_thicks = [9,14,21];
30
31 module Tests(){ ////toplevel
32   for (thicki=[0:len(test_thicks)-1]) {
33     translate([thicki*test_width-0.5, 0, 0]) {
34       difference(){
35         cube([test_width,
36               test_thicks[thicki] + led_depth,
37               test_height]);
38         translate([test_width/2, -1, test_height/2])
39           rotate([-90,0,0])
40           cylinder(r=led_dia/2, h=led_depth+1, $fn=30);
41       }
42     }
43   }
44 }
45
46 //Tests();
47
48 //--- real thing ---
49
50 tower_overhang = led_dia * 2.5;
51
52 tower_over_max_y = tower_overhang * sin(tower_over_angle);
53 tower_over_max_z = tower_frontheight + tower_overhang * cos(tower_over_angle);
54 tower_total_max_z = tower_over_max_z + vert_space_inside + led_depth;
55 tower_rearwall_y = -(backfront_space_inside + tower_wall_thick);
56
57 backfront_mate_extra = (backfront_mate_size - (-tower_rearwall_y));
58
59 module TowerWallCrossSection(){
60   // generates a 2D shape - a polygon
61   // x is what is going to be -y
62   // y is what is going to be z
63   polygon([[0,                  0],
64            [0,                  tower_frontheight],
65            [-tower_over_max_y,  tower_over_max_z],
66            [-tower_over_max_y
67             + tan(tower_forehead_angle) * (vert_space_inside + led_depth),
68             tower_total_max_z],
69            [-tower_rearwall_y,  tower_total_max_z],
70            [-tower_rearwall_y,  0],
71            [-tower_rearwall_y, -tower_base_height],
72            [-backfront_mate_extra, -tower_base_height]]);
73 }
74
75 module TowerWallSomeEdge(front){
76   minkowski(){
77     difference(){
78       TowerWallCrossSection();
79       translate([front ? 0.10 : -0.10, 0])
80         TowerWallCrossSection();
81     }
82     circle(r=tower_wall_thick, $fn=8);
83   }
84 }
85
86 module TowerBulkCrossSection(){
87   intersection(){
88     TowerWallCrossSection();
89     union(){
90       translate([-tower_over_max_y/2,
91                  tower_frontheight + tower_overhang*sin(tower_over_angle)/2])
92         circle(r = led_depth);
93       TowerWallSomeEdge(true);
94       translate([-50, -50])
95         square([100, 50]);
96     }
97   }
98 }
99
100 module TowerRearWallCrossSection(){
101   intersection(){
102     TowerWallCrossSection();
103     union(){
104       intersection(){
105         translate([0,-10]) square([100, 10+tower_frontheight]);
106         TowerWallSomeEdge(false);
107       }
108       TowerBulkCrossSection();
109     }
110   }
111 }
112
113
114 module TowerCrossSectionDemo(){
115   %TowerWallCrossSection();
116   //TowerBulkCrossSection();
117   TowerRearWallCrossSection();
118 }
119
120 module TowerMain(){
121   for (mir=[0,1])
122     mirror([mir,0,0]) rotate([90,0,-90]) {
123       translate([0,0, tower_width/2-tower_wall_thick])
124         linear_extrude(height=tower_wall_thick)
125         TowerWallCrossSection();
126       translate([0,0,-1])
127         linear_extrude(height=tower_width/2+0.9)
128         TowerBulkCrossSection();
129       translate([0,0, tower_slot_width/2])
130         linear_extrude(height=(tower_width - tower_slot_width)/2 - 0.2)
131         TowerRearWallCrossSection();
132     }
133 }
134
135 module Tower(){
136   difference(){
137     TowerMain();
138   }
139 }
140
141 //TowerCrossSectionDemo();
142 //TowerWallSomeEdge(false);
143 //TowerWallFrontEdge();
144 Tower();