chiark / gitweb /
bike-lipo-box: wip
[reprap-play.git] / bike-lipo-box.scad.m4
1 // -*- C -*-
2
3 include <commitid.scad>
4 include <utils.scad>
5
6 pxp6012_rad = 22.5 / 2 + 0.5;
7 pxp6012_rad_outer = 32.0 / 2 - 0.5;
8
9 s1930_y = 30.2 + 0.2;
10 s1930_x =   22 + 0.2;
11 s1930_y_outer = 36.4 + 0.2;
12 s1930_x_outer = 27.6 + 0.2;
13
14 s1930_recess = 3;
15 s1930_around = 3;
16
17 wallthick = 3.0;
18
19 module TestWall(){
20   sw_ctr = [25, 0, 25];
21
22   rotate([0,0,-90]){
23     difference(){
24       union(){
25         cube([50, wallthick, 42]);
26       }
27
28       translate([30, -1, 20])
29         rotate([-90,0,0])
30         cylinder(r = pxp6012_rad, h=10, $fn=60);
31
32       rotate([90,0,0])
33         Commitid_BestCount([15,40]);
34     }
35   }
36
37   difference(){
38     union(){
39       cube([50, wallthick, 50]);
40       translate(sw_ctr) {
41         rotate([90,0,0])
42           cube([s1930_x_outer + s1930_around,
43                 s1930_y_outer + s1930_around,
44                 s1930_recess*2],
45                center=true);
46       }
47     }
48
49     translate(sw_ctr) {
50       rotate([90,0,0]) {
51         cube([s1930_x, s1930_y, 10], center=true);
52         translate([0,0, -5])
53           cube([s1930_x_outer, s1930_y_outer, 10], center=true);
54       }
55     }
56   }    
57 }
58
59 floorth = 2.5;
60 ceilth = 2.5;
61 innertube = 1.0 + 0.2;
62 lidoverlap = 1.5;
63 lidoverhang = 4;
64
65 ts_xbox = 30;
66 ts_ybox = 25;
67 ts_cnrrad = 10;
68 ts_zbox = 15;
69
70 m4_dnl Box_Part($1=transl_x,$2=transl_y, $3=rot_z,$4=mirror_xy)
71 m4_dnl          $5=kind, $6=kindargs, $7=profile(profileargsargs))
72 m4_define(`Box_Part',`
73   translate([($1),($2)])
74     rotate([0,0,($3)])
75     mirror([($4),0,0])
76     BoxPart_Extrude_$5($6, $7)') m4_dnl
77
78 boxpart_d = 0.01;
79
80 m4_dnl BoxPart_Extrude_Linear(dist, `profile(...);');
81 m4_define(`BoxPart_Extrude_Linear',`
82   rotate([90,0,0])
83     translate([0,0, -($1)])
84     linear_extrude(height= boxpart_d + ($1)) {
85       $2
86     }
87 ')
88
89 m4_dnl BoxPart_Extrude_Arc(x0_radius, swept_angle, `profile(...);')
90 m4_dnl  arc starting at transl_x, transl_y, moving towards positive
91 m4_dnl  y at first and then bending towards negative x, until
92 m4_dnl  use negative x0_radius to inciate bending towards positive x
93 m4_dnl  swept_angle is reached
94 m4_dnl  x0_radius is the radius of the extruded part at x=0, not of the box
95 m4_define(`BoxPart_Extrude_Arc',`
96   translate([-($1),0,0])
97     intersection(){
98       translate([0,0,-500])
99         linear_extrude(height=1000)
100         scale(500)
101         mirror([($1)<0, 0,0])
102         FArcSegment_mask($2);
103       rotate_extrude(convexity=10, $fs=1, $fn=36)
104         mirror([($1)<0, 0,0])
105         translate([+($1),0,0]){
106           $3
107         }
108     }
109 ')
110
111 ts_xbox_lin = ts_xbox - ts_cnrrad*2;
112 ts_ybox_lin = ts_ybox - ts_cnrrad*2;
113
114 m4_dnl TestSealDoBoxShape(`profile(profileargs)');
115 m4_define(`TestSealDoBoxShape',`
116   Box_Part(0,               ts_cnrrad,    0,0, Linear,`ts_ybox_lin', `$1' )
117   Box_Part(0, ts_ybox-ts_cnrrad,          0,0, Arc,`-ts_cnrrad,90' , `$1' )
118   Box_Part(ts_cnrrad,       ts_ybox,    -90,0, Linear,`ts_xbox_lin', `$1' )
119   Box_Part(ts_xbox-ts_cnrrad, ts_ybox,  -90,0, Arc,`-ts_cnrrad,90' , `$1' )
120   Box_Part(ts_xbox, ts_ybox-ts_cnrrad, -180,0, Linear,`ts_ybox_lin', `$1' )
121   Box_Part(ts_xbox,         ts_cnrrad, -180,0, Arc,`-ts_cnrrad,90' , `$1' )
122   Box_Part(ts_xbox-ts_cnrrad, 0,       -270,0, Linear,`ts_xbox_lin', `$1' )
123   Box_Part(ts_cnrrad,         0,       -270,0, Arc,`-ts_cnrrad,90' , `$1' )
124 ')
125
126 m4_dnl '
127
128 module WallProfile(){
129   z = ts_zbox - innertube - wallthick/2;
130   translate([0, -0.1]) square([wallthick, z]);
131   translate([wallthick/2, z]) circle(r = wallthick/2, $fn=20);
132 }
133
134 module FloorProfile(){
135   mirror([0,1]) square([wallthick, floorth]);
136 }
137
138 module LidProfile(){
139   rad = wallthick/2 + innertube;
140   morex = wallthick;
141   difference(){
142     translate([-lidoverlap - innertube,
143                ts_zbox - lidoverhang - innertube])
144       square([lidoverlap + innertube + wallthick + morex,
145               lidoverhang + innertube + ceilth]);
146     hull(){
147       translate([wallthick/2, ts_zbox - innertube - wallthick/2])
148         for (t=[ [0,0],
149                  [morex*2, 0],
150                  [0, -ts_zbox]
151                  ]) {
152           translate(t)
153             circle(r= wallthick/2 + innertube, $fn=20);
154         }
155     }
156   }
157 }
158
159 module TestSealBox(){
160   TestSealDoBoxShape(WallProfile(););
161   hull(){ TestSealDoBoxShape(FloorProfile();); }
162 }
163
164 module ProfileDemos(){
165   WallProfile();
166   color("blue")
167     FloorProfile();
168   LidProfile();
169 }
170                           
171 //TestWall();
172 //TestSealBox();
173 ProfileDemos();
174 //FArcSegment_mask(350);