Skip to content

Commit b5bdd56

Browse files
committed
fix trigonometry for "frontside angle"
1 parent 0bcad4c commit b5bdd56

3 files changed

Lines changed: 65 additions & 39 deletions

File tree

src/MainCase/MainCase.scad

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module MainCaseBody(reduce=0, depth=OBS_depth) {
1010
polygon(polyRound([
1111
[reduce, reduce, MainCase_small_corner_radius-reduce],
1212
[OBS_height-reduce, reduce, MainCase_small_corner_radius-reduce],
13-
[OBS_height-reduce, OBS_width-reduce, 16-reduce],
13+
[OBS_height-reduce, OBS_width-reduce/tan((90-frontside_angle)/2), 16-reduce],
1414
[reduce, OBS_width_small-reduce, 16-reduce],
1515
], fn=$pfn));
1616
}
@@ -120,6 +120,20 @@ module GpsAntennaLid() {
120120
}
121121
}
122122

123+
module SwitchboxPolygon(padding=0,height=1, depth=12, width=15) {
124+
linear_extrude(height)polygon(
125+
polyRound([
126+
[-width-1-padding,.05,0],
127+
[-width-padding,0.1,1.5],
128+
[-width+4-padding,-depth-padding,3],
129+
[width-4+padding,-depth-padding,3],
130+
[width+padding,0.05,1.5],
131+
[width+1+padding,0.05,0]
132+
]),$fn=$pfn
133+
);
134+
}
135+
136+
123137
module MainCase(without_inserts=false, top_rider=MainCase_top_rider, back_rider=MainCase_back_rider) {
124138
difference() {
125139
union() {
@@ -151,7 +165,7 @@ module MainCase(without_inserts=false, top_rider=MainCase_top_rider, back_rider=
151165
HeatsetInsertStandoff(OBS_height - MainCase_pcb_holes[2].x - 2 * wall_thickness - MainCase_pcb_offset[0]);
152166

153167
translate([MainCase_pcb_holes[3].x, MainCase_pcb_holes[3].y, 0])
154-
rotate([0, 0, -90])
168+
rotate([0, 0, 0])
155169
HeatsetInsertStandoff(OBS_height - MainCase_pcb_holes[3].x - 2 * wall_thickness - MainCase_pcb_offset[0]);
156170
}
157171
}
@@ -200,38 +214,46 @@ module MainCase(without_inserts=false, top_rider=MainCase_top_rider, back_rider=
200214
[0, 8, 0],
201215
], fn=$pfn));
202216

203-
// Hole 4
204-
*translate([OBS_height-MainCaseLid_hole4_offset_x, OBS_width-sin(frontside_angle)*TopHole4_offset_top, 0])
205-
rotate([0, 0, frontside_angle]) {
206-
translate([0, -wall_thickness, 0])
217+
218+
// The switch box
219+
slope_length = (OBS_height)/cos(frontside_angle);
220+
difference(){
221+
translate([0, OBS_width_small, 0])
207222
linear_extrude(OBS_depth)
223+
rotate([0,0,-90+frontside_angle])
208224
polygon(polyRound([
209-
[10, 0, 0],
210-
[4.5, 0, 3],
211-
[4.5, -9-sin(frontside_angle)*9, 3],
212-
[-4.5, -9, 3],
213-
[-4.5, 0, 3],
214-
[-10, 0, 0],
225+
[0,(MainCase_switch_offset_x)/OBS_height*slope_length-11, 0],
226+
227+
[13,(MainCase_switch_offset_x)/OBS_height*slope_length-11,03],
228+
[13,(MainCase_switch_offset_x)/OBS_height*slope_length+11,03],
229+
[8,(MainCase_switch_offset_x)/OBS_height*slope_length+11,03],
230+
//[12,(MainCase_switch_offset_x)/OBS_height*slope_length+25, 5],
231+
232+
[8,MainCaseLid_hole_positions[4][0]/OBS_height*slope_length+4,5],
233+
[0,(MainCase_switch_offset_x)/OBS_height*slope_length+27, 0]
234+
215235
], fn=$pfn));
236+
translate([0, 64, 0])
237+
cube([16,10,12]);
216238
}
239+
translate([MainCase_switch_offset_x, OBS_width_small+tan(frontside_angle)*MainCase_switch_offset_x, 0])
240+
rotate([0, 0, frontside_angle])
241+
SwitchboxPolygon(padding=wall_thickness, height=100);
217242

218-
// Hole 5
243+
// hole 5
219244
difference(){
220245
translate([wall_thickness, 75, 0])
221246
linear_extrude(OBS_depth)
222247
polygon(polyRound([
223-
[0, -4, 0],
224-
[8, -4, 3],
225-
[8, sin(frontside_angle)*8, 1],
226-
[36, sin(frontside_angle)*36, 3],
227-
[36, sin(frontside_angle)*36+5, 3],
228-
[43, sin(frontside_angle)*43+5, 3],
229-
[43, 100, 0],
230-
[0, 100, 0],
248+
[0, -4, 0],
249+
[8, -4, 1],
250+
[8, 3, 1],
251+
[0,3, 0],
231252
], fn=$pfn));
232253
translate([0, 64, 0])
233254
cube([16,10,12]);
234255
}
256+
235257
}
236258
}
237259

@@ -280,7 +302,7 @@ module MainCase(without_inserts=false, top_rider=MainCase_top_rider, back_rider=
280302
], fn=$pfn));
281303

282304
// a little standoff for the PCB
283-
#translate([wall_thickness, MainCase_pcb_offset.y + wall_thickness, wall_thickness])
305+
translate([wall_thickness, MainCase_pcb_offset.y + wall_thickness, wall_thickness])
284306
linear_extrude(m3_insert_hole_depth)
285307
polygon(polyRound([
286308
[0, 0, 0],
@@ -315,7 +337,7 @@ module MainCase(without_inserts=false, top_rider=MainCase_top_rider, back_rider=
315337
}
316338

317339
// The hole for the sensor
318-
translate([OBS_height-16, OBS_width-16-sin(frontside_angle)*16, 0]) {
340+
translate([OBS_height-16, OBS_width-1/tan((90-frontside_angle)/2)*16, 0]) {
319341
translate([0, 0, -2])
320342
cylinder(r=MainCase_sensor_hole_diameter/2, h=70+4);
321343

@@ -344,15 +366,20 @@ module MainCase(without_inserts=false, top_rider=MainCase_top_rider, back_rider=
344366
}
345367

346368
// Cutouts and hole for switch
347-
translate([MainCase_switch_offset_x, OBS_width_small+sin(frontside_angle)*MainCase_switch_offset_x, wall_thickness+4])
369+
translate([MainCase_switch_offset_x, OBS_width_small+tan(frontside_angle)*MainCase_switch_offset_x, wall_thickness+4])
348370
rotate([0, 0, frontside_angle]) {
349-
// Square cutout on outside
350-
translate([0, 0, 11]){
351-
cube([22, 24, 21.6], center=true);
352-
translate([0,-(24-6)/2+3,0.4])cube([22,6, 22], center=true);
353-
translate([0,-(24-6)/2+3,0.8])cube([6,6, 22], center=true);
371+
SwitchboxPolygon(padding=0, height=21.6);
372+
if (enable_easy_print) {
373+
intersection(){
374+
SwitchboxPolygon(padding=0, height=29.2);
375+
translate([0, 0, 21.6/2]){
376+
union(){
377+
translate([0,-(24-6)/2+3,0.3])cube([60,6, 21.6], center=true);
378+
translate([0,-(24-6)/2+3,0.6])cube([6,6, 21.6], center=true);
379+
}
380+
}
381+
}
354382
}
355-
356383
// Hole for the switches' lever
357384
translate([0, -4-wall_thickness, 8])
358385
cylinder(d=6, h=20);
@@ -361,10 +388,10 @@ module MainCase(without_inserts=false, top_rider=MainCase_top_rider, back_rider=
361388
translate([0, -wall_thickness, 24])
362389
linear_extrude(200)
363390
polygon(polyRound([
364-
[-16, -20, 0],
365-
[-16, 0, 4],
366-
[16, 0, 4],
367-
[16, -20, 0],
391+
[-15.1, -20, 0],
392+
[-15.1, 0, 4],
393+
[15.1, 0, 4],
394+
[15.1, -20, 0],
368395
], fn=$pfn));
369396
}
370397

src/MainCase/MainCaseLid.scad

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module MainCaseLid() {
4141
rim_offset = wall_thickness + MainCaseLid_rim_clearance;
4242
hole_x = 75;
4343

44-
dx = function (x) x * sin(frontside_angle);
44+
dx = function (x) x * tan(frontside_angle);
4545
polygon(polyRound([
4646
[rim_offset+MainCaseLid_rim_radius, rim_offset, 0],
4747
[rim_offset+MainCaseLid_rim_radius, rim_offset+MainCaseLid_rim_radius, MainCaseLid_rim_radius],
@@ -110,7 +110,7 @@ module MainCaseLid() {
110110
}
111111

112112
// Hole for the sensor
113-
translate([OBS_height-16, OBS_width-16-sin(frontside_angle)*16, 0]) {
113+
translate([OBS_height-16, OBS_width-1/tan((90-frontside_angle)/2)*16, 0]) {
114114
translate([0, 0, -15])
115115
cylinder(r=MainCase_sensor_hole_diameter/2, h=20);
116116
}

variables.scad

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ MainCase_micro_usb_offset = 30 + MainCase_pcb_offset.y + wall_thickness;
141141
MainCase_micro_usb_width = 16;
142142
MainCase_micro_usb_height = 14;
143143

144-
// TODO: this is only almost correct
145-
frontside_angle = asin((OBS_width - OBS_width_small) / OBS_height);
144+
frontside_angle = atan((OBS_width - OBS_width_small) / OBS_height);
146145

147146
MainCaseLid_rim_clearance = 0.3;
148147
MainCaseLid_rim_thickness = 3.0;
@@ -157,7 +156,7 @@ MainCaseLid_hole_positions = [
157156
[OBS_height-MainCaseLid_hole_offset-wall_thickness, MainCaseLid_hole_offset+wall_thickness],
158157
[MainCaseLid_hole_offset+wall_thickness, OBS_width_small-MainCaseLid_hole_offset-wall_thickness-8],
159158
[OBS_height-MainCaseLid_hole_offset-wall_thickness, OBS_width_small-MainCaseLid_hole_offset-wall_thickness-8],
160-
[OBS_height-MainCaseLid_hole4_offset_x+4.5, OBS_width-sin(frontside_angle)*MainCaseLid_hole4_offset_x-3],
159+
[OBS_height-MainCaseLid_hole4_offset_x+4.5*cos(frontside_angle), OBS_width-tan(frontside_angle)*MainCaseLid_hole4_offset_x-3.5],
161160
];
162161

163162
MainCaseLid_battery_holder_lift = 1.5;

0 commit comments

Comments
 (0)