瀏覽代碼

added first rail laser test

Thomas Buck 1 年之前
父節點
當前提交
0468dd7eaa
共有 2 個文件被更改,包括 263 次插入0 次删除
  1. 202
    0
      rail-laser/rail-laser.scad
  2. 61
    0
      rail-laser/roundedcube.scad

+ 202
- 0
rail-laser/rail-laser.scad 查看文件

@@ -0,0 +1,202 @@
1
+include <roundedcube.scad>
2
+
3
+$fn = 50;
4
+
5
+rail_width = 21.0 + 0.2;
6
+rail_height = 6.0 + 0.2 + 2;
7
+rail_lip_width_small = 1.5 - 0.2;
8
+rail_lip_width_big = 3.5 - 0.2;
9
+rail_lip_height = 1.1 - 0.1;
10
+
11
+module rail_lip(l) {
12
+    hull() {
13
+        translate([-1, -0.1, 0])
14
+        cube([l + 2, 0.2, rail_lip_width_big]);
15
+        translate([-1, rail_lip_height - 0.1, (rail_lip_width_big - rail_lip_width_small) / 2])
16
+        cube([l + 2, 0.1, rail_lip_width_small]);
17
+    }
18
+}
19
+
20
+module rail(l) {
21
+    difference() {
22
+        cube([l, rail_width, rail_height]);
23
+        
24
+        translate([0, 0, rail_height - rail_lip_width_big]) {
25
+            rail_lip(l);
26
+            
27
+            translate([l, rail_width, 0])
28
+            rotate([0, 0, 180])
29
+            rail_lip(l);
30
+        }
31
+    }
32
+}
33
+
34
+laser_dia = 6.5;
35
+laser_len = 14.0;
36
+
37
+module laser() {
38
+    cylinder(d = laser_dia, h = laser_len);
39
+}
40
+
41
+frame_gap = 0.2;
42
+frame_sphere = 20;
43
+frame_add_touch = 4.0;
44
+frame_wall = 1.5;
45
+frame_mount_hole = 2.0;
46
+frame_mid_len = frame_mount_hole + (2 * frame_wall);
47
+frame_mid_dia = laser_dia + (2 * frame_wall);
48
+frame_tail_len = 8.0;
49
+frame_tail_width = frame_mid_dia + 0.5;
50
+frame_negative_width = frame_sphere * 2 / 3 + 7;
51
+frame_hole_dia = 2.9;
52
+frame_hole_off = 1.8;
53
+frame_hole_neg_off = 10;
54
+frame_hole_neg_len = 15;
55
+frame_hole_neg_deg_a = 9;
56
+frame_hole_neg_deg_b = frame_hole_neg_deg_a;
57
+frame_hole_neg_rad_small = frame_mid_len + ((frame_sphere + frame_tail_len) / 2) - frame_hole_off;
58
+frame_hole_neg_rad_large = frame_mid_len + ((frame_sphere + frame_tail_len) / 2) + frame_hole_off;
59
+frame_len = frame_sphere + frame_mid_len + frame_tail_len;
60
+
61
+module laser_frame_screw_arc(radius, deg) {
62
+    for (r = [-deg : 1 : deg])
63
+    translate([radius, 0, 0])
64
+    rotate([0, 0, r])
65
+    translate([-radius, 0, 0])
66
+    cylinder(d = frame_hole_dia, h = frame_negative_width + frame_hole_neg_len);
67
+}
68
+
69
+module laser_frame(added_gap = 0, negative = 0) {
70
+    difference() {
71
+        union() {
72
+            translate([0, 0, (frame_sphere / 2) + (frame_len - frame_sphere)])
73
+            sphere(d = frame_sphere + added_gap);
74
+            
75
+            if (negative == 0) {
76
+                translate([0, 0, frame_len - frame_sphere - frame_mid_len - 0.5])
77
+                cylinder(d = frame_mid_dia + added_gap, h = frame_mid_len + frame_add_touch + 1.0);
78
+                
79
+                translate([-(frame_tail_width + added_gap) / 2, -(frame_tail_width + added_gap) / 2, frame_len - frame_sphere - frame_mid_len - frame_tail_len])
80
+                roundedcube([frame_tail_width + added_gap, frame_tail_width + added_gap, frame_tail_len]);
81
+            } else {
82
+                translate([0, 0, frame_len - frame_add_touch])
83
+                cylinder(d = laser_dia + added_gap, h = frame_mid_len + frame_add_touch);
84
+                
85
+                translate([-frame_negative_width / 2, -frame_negative_width / 2, frame_len - frame_sphere - frame_mid_len - frame_tail_len - (added_gap * 3) - 1])
86
+                cube([frame_negative_width, frame_negative_width, frame_len - frame_sphere + frame_add_touch + (added_gap * 3) + 1]);
87
+            
88
+                translate([-frame_hole_neg_off + frame_negative_width + frame_hole_neg_len, 0, frame_len - frame_sphere - frame_mid_len - frame_tail_len + (frame_tail_len / 2) - frame_hole_off])
89
+                rotate([0, -90, 0])
90
+                laser_frame_screw_arc(frame_hole_neg_rad_large, frame_hole_neg_deg_a);
91
+            
92
+                translate([0, -frame_hole_neg_off, frame_len - frame_sphere - frame_mid_len - frame_tail_len + (frame_tail_len / 2) + frame_hole_off])
93
+                rotate([-90, -90, 0])
94
+                laser_frame_screw_arc(frame_hole_neg_rad_small, frame_hole_neg_deg_b);
95
+            }
96
+        }
97
+        
98
+        if (negative == 0) {
99
+            translate([0, 0, -1])
100
+            cylinder(d = laser_dia + (2 * frame_gap), h = frame_len + 2);
101
+        
102
+            translate([0, 0, (frame_len - frame_sphere - frame_mid_len) + (frame_mid_len / 2)])
103
+            rotate([0, 90, 0]) {
104
+                cylinder(d = frame_mount_hole, h = frame_mid_dia);
105
+            
106
+                rotate([-90, 0, 0])
107
+                cylinder(d = frame_mount_hole, h = frame_mid_dia);
108
+            }
109
+            
110
+            translate([-frame_tail_width / 2 - 1, 0, frame_len - frame_sphere - frame_mid_len - frame_tail_len + (frame_tail_len / 2) - frame_hole_off])
111
+            rotate([0, 90, 0])
112
+            cylinder(d = frame_hole_dia, h = frame_tail_width + 2);
113
+            
114
+            translate([0, -frame_tail_width / 2 - 1, frame_len - frame_sphere - frame_mid_len - frame_tail_len + (frame_tail_len / 2) + frame_hole_off])
115
+            rotate([-90, 0, 0])
116
+            cylinder(d = frame_hole_dia, h = frame_tail_width + 2);
117
+        }
118
+    }
119
+}
120
+
121
+body_width = 25.0;
122
+body_length = 45.0;
123
+body_height = 35.0;
124
+body_frame_gap = 0.5;
125
+body_frame_off = 15;
126
+body_cube_rounding = 1.0;
127
+
128
+body_hole_dia = 2.2;
129
+body_hole_off_x = 2.2;
130
+body_hole_off_z = body_hole_off_x;
131
+
132
+module body() {
133
+    difference() {
134
+        //cube([body_length, body_width, body_height]);
135
+        roundedcube([body_length, body_width, body_height], false, body_cube_rounding);
136
+        
137
+        translate([-1, (body_width - rail_width) / 2, body_height - rail_height + 0.1])
138
+        rail(body_length + 2);
139
+        
140
+        translate([body_length - frame_len, body_width / 2, body_frame_off])
141
+        rotate([0, 90, 0]) {
142
+            laser_frame(body_frame_gap, 1);
143
+            %laser_frame();
144
+        }
145
+        
146
+        translate([body_hole_off_x, -1, body_hole_off_z])
147
+        rotate([-90, 0, 0])
148
+        cylinder(d = body_hole_dia, h = body_width + 2);
149
+        translate([body_length - body_hole_off_x, -1, body_hole_off_z])
150
+        rotate([-90, 0, 0])
151
+        cylinder(d = body_hole_dia, h = body_width + 2);
152
+        translate([body_hole_off_x, -1, body_height - rail_height - body_hole_off_z])
153
+        rotate([-90, 0, 0])
154
+        cylinder(d = body_hole_dia, h = body_width + 2);
155
+        translate([body_length - body_hole_off_x, -1, body_height - rail_height - body_hole_off_z])
156
+        rotate([-90, 0, 0])
157
+        cylinder(d = body_hole_dia, h = body_width + 2);
158
+        
159
+        translate([-1, body_width / 2, body_height / 2.35])
160
+        rotate([0, 90, 0])
161
+        cylinder(d = 10, h = 20);
162
+    }
163
+}
164
+
165
+bodies_gap = 0.05;
166
+
167
+module body_half(half = 0) {
168
+    difference() {
169
+        body();
170
+        
171
+        if (half == 0) {
172
+            translate([-1, (bodies_gap - body_width) / 2, -1])
173
+            cube([body_length + 2, body_width, body_height + 2]);
174
+        } else {
175
+            translate([-1, (body_width - bodies_gap) / 2, -1])
176
+            cube([body_length + 2, body_width, body_height + 2]);
177
+            
178
+        }
179
+    }
180
+}
181
+
182
+module print() {
183
+    translate([0, 0, body_width])
184
+    rotate([-90, 0, 0])
185
+    body_half(0);
186
+    
187
+    translate([0, body_height * 2 + 5, 0])
188
+    rotate([90, 0, 0])
189
+    body_half(1);
190
+    
191
+    translate([body_length + 10, body_height + 2, 0])
192
+    laser_frame(0, 0);
193
+}
194
+
195
+//laser_frame(0, 0);
196
+//laser_frame(0.5, 1);
197
+
198
+//body_half(0);
199
+//body_half(1);
200
+//body();
201
+
202
+print();

+ 61
- 0
rail-laser/roundedcube.scad 查看文件

@@ -0,0 +1,61 @@
1
+// Higher definition curves
2
+$fs = 0.01;
3
+
4
+module roundedcube(size = [1, 1, 1], center = false, radius = 0.5, apply_to = "all") {
5
+	// If single value, convert to [x, y, z] vector
6
+	size = (size[0] == undef) ? [size, size, size] : size;
7
+
8
+	translate_min = radius;
9
+	translate_xmax = size[0] - radius;
10
+	translate_ymax = size[1] - radius;
11
+	translate_zmax = size[2] - radius;
12
+
13
+	diameter = radius * 2;
14
+
15
+	module build_point(type = "sphere", rotate = [0, 0, 0]) {
16
+		if (type == "sphere") {
17
+			sphere(r = radius);
18
+		} else if (type == "cylinder") {
19
+			rotate(a = rotate)
20
+			cylinder(h = diameter, r = radius, center = true);
21
+		}
22
+	}
23
+
24
+	obj_translate = (center == false) ?
25
+		[0, 0, 0] : [
26
+			-(size[0] / 2),
27
+			-(size[1] / 2),
28
+			-(size[2] / 2)
29
+		];
30
+
31
+	translate(v = obj_translate) {
32
+		hull() {
33
+			for (translate_x = [translate_min, translate_xmax]) {
34
+				x_at = (translate_x == translate_min) ? "min" : "max";
35
+				for (translate_y = [translate_min, translate_ymax]) {
36
+					y_at = (translate_y == translate_min) ? "min" : "max";
37
+					for (translate_z = [translate_min, translate_zmax]) {
38
+						z_at = (translate_z == translate_min) ? "min" : "max";
39
+
40
+						translate(v = [translate_x, translate_y, translate_z])
41
+						if (
42
+							(apply_to == "all") ||
43
+							(apply_to == "xmin" && x_at == "min") || (apply_to == "xmax" && x_at == "max") ||
44
+							(apply_to == "ymin" && y_at == "min") || (apply_to == "ymax" && y_at == "max") ||
45
+							(apply_to == "zmin" && z_at == "min") || (apply_to == "zmax" && z_at == "max")
46
+						) {
47
+							build_point("sphere");
48
+						} else {
49
+							rotate = 
50
+								(apply_to == "xmin" || apply_to == "xmax" || apply_to == "x") ? [0, 90, 0] : (
51
+								(apply_to == "ymin" || apply_to == "ymax" || apply_to == "y") ? [90, 90, 0] :
52
+								[0, 0, 0]
53
+							);
54
+							build_point("cylinder", rotate);
55
+						}
56
+					}
57
+				}
58
+			}
59
+		}
60
+	}
61
+}

Loading…
取消
儲存