chiark / gitweb /
fairphone-battery-case: base indent
[reprap-play.git] / fairphone-battery-case.scad
1 // -*- C -*-
2
3 mainwall_th = 2.5;
4 smallwall_th = 1.5;
5
6 seal_th = 0.3 + 0.6; // total gap for seal etc.
7 behind_recess = 1.0;
8
9 recess_gap_end = 0.2;
10
11 lid_edge_th = 0.5;
12
13 battery_len = 66.55 + 0.75;
14 battery_th = 6.55 + 0.75;
15 battery_wdth = 44.38 + 0.75;
16
17 battery_base_indent = 0.94 + 0.50;
18 battery_base_indent_fromside_outside = 4;
19 battery_base_indent_fromside_inside = 10;
20
21 // for testing:
22 battery_len = 3;
23 battery_wdth = 15;
24 battery_base_indent_fromside_inside = 6;
25
26 // calculated
27
28 bpp0 = [0,0];
29 bpp1 = bpp0 + [ 0, mainwall_th - behind_recess ];
30 lppA = bpp1 + [ seal_th, -recess_gap_end ];
31 lppB = lppA + [ lid_edge_th, 0 ];
32 bpp2 = [ lppB[0], bpp1[1] ];
33 bpp3 = [ bpp2[0] + (bpp1 - bpp0)[1], bpp0[1] ];
34 bpp4 = [ bpp3[0], bpp0[1] + mainwall_th ];
35 lppC = bpp3 + [ 0, -recess_gap_end ];
36
37 s0 = battery_wdth/2;
38 s1 = s0 + smallwall_th;
39
40 echo(
41      bpp0,
42      bpp1,
43      bpp2,
44      bpp3,
45      bpp4,
46      bpp5,
47      bpp6,
48      bpp7,
49      bpp8
50 );
51
52 echo(
53      lppA,
54      lppB,
55      lppC,
56      lppD,
57      lppE
58 );
59
60 bpp8 = bpp0 + [ -battery_len,0 ];
61 bpp5 = [ bpp8[0] - smallwall_th, bpp4[1] ];
62 bpp9 = [ bpp0[0], bpp0[1] - battery_th/2 - 1.0 ];
63 bpp7 = [ bpp8[0], bpp9[1] ];
64 bpp6 = [ bpp5[0], bpp9[1] ];
65 lppE = [ lppA[0], bpp9[1] ];
66 lppD = [ lppC[0], bpp9[1] ];
67
68 module BaseHalfPlan(indent=0){
69   polygon([ bpp0,
70             bpp1,
71             bpp2,
72             bpp3,
73             bpp4,
74             bpp5,
75             bpp6,
76             bpp7 + indent * [1,0],
77             bpp8 + indent * [1,0]
78             ]);
79 }
80
81 module SideHalfPlan(){
82   polygon([ bpp5,
83             bpp6,
84             bpp9,
85             bpp1
86             ]);
87 }
88
89 module LidHalfPlan(){
90   polygon([ lppA,
91             lppE,
92             lppD,
93             lppC,
94             lppB
95             ]);
96 }
97
98 module ExtrudePlan(from,to){
99   rotate([0,-90,0])
100   for (mj=[0,1]) {
101     mirror([0,0,mj]) translate([0,0,from]){
102       linear_extrude(height= to-from){
103         for (mi=[0,1]) {
104           mirror([0,mi])
105             translate([0, battery_th/2])
106             children(0);
107         }
108       }
109     }
110   }
111 }
112
113 module PlanDemo(){ ////toplevel
114   color("blue") BaseHalfPlan();
115   color("red") LidHalfPlan();
116   translate([0,0,-1]) color("lightblue") SideHalfPlan();
117 }
118
119 module Base(){ ////toplevel
120   ExtrudePlan(0,s1) BaseHalfPlan();
121   ExtrudePlan(s0,s1) SideHalfPlan();
122   ExtrudePlan(s0 - battery_base_indent_fromside_inside,
123               s0 - battery_base_indent_fromside_outside
124               ) SideHalfPlan(indent = battery_base_indent);
125 }
126
127 module Lid(){ ////toplevel
128   ExtrudePlan(0,s1) LidHalfPlan();
129 }
130
131 module Demo(){ ////toplevel
132   %Base();
133   Lid();
134 }
135
136 //PlanDemo();
137 //Demo();
138 //Base();