chiark / gitweb /
a468a1592cd781473ad8b60b204609650cdb707a
[reprap-play.git] / bike-lipo-box.scad.m4
1 // -*- C -*-
2
3 include <commitid.scad>
4
5 pxp6012_rad = 22.5 / 2 + 0.5;
6 pxp6012_rad_outer = 32.0 / 2 - 0.5;
7
8 s1930_y = 30.2 + 0.2;
9 s1930_x =   22 + 0.2;
10 s1930_y_outer = 36.4 + 0.2;
11 s1930_x_outer = 27.6 + 0.2;
12
13 s1930_recess = 3;
14 s1930_around = 3;
15
16 wallthick = 3.0;
17
18 module TestWall(){
19   sw_ctr = [25, 0, 25];
20
21   rotate([0,0,-90]){
22     difference(){
23       union(){
24         cube([50, wallthick, 42]);
25       }
26
27       translate([30, -1, 20])
28         rotate([-90,0,0])
29         cylinder(r = pxp6012_rad, h=10, $fn=60);
30
31       rotate([90,0,0])
32         Commitid_BestCount([15,40]);
33     }
34   }
35
36   difference(){
37     union(){
38       cube([50, wallthick, 50]);
39       translate(sw_ctr) {
40         rotate([90,0,0])
41           cube([s1930_x_outer + s1930_around,
42                 s1930_y_outer + s1930_around,
43                 s1930_recess*2],
44                center=true);
45       }
46     }
47
48     translate(sw_ctr) {
49       rotate([90,0,0]) {
50         cube([s1930_x, s1930_y, 10], center=true);
51         translate([0,0, -5])
52           cube([s1930_x_outer, s1930_y_outer, 10], center=true);
53       }
54     }
55   }    
56 }
57
58 ts_floorceil = 1.5;
59 ts_outer = [20,20,20];
60 ts_wall = [wallthick,wallthick,ts_floorceil];
61
62 ts_xbox = 20;
63 ts_ybox = 15;
64 ts_cnrrad = 5;
65 ts_zbox = 20;
66
67 ts_innertube = 0.1;
68
69 m4_dnl Box_Part($1=transl_x,$2=transl_y, $3=rot_z,$4=mirror_xy)
70 m4_dnl          $5=kind, $6=kindargs, $7=profile(profileargsargs))
71 m4_define(`Box_Part',`
72   translate([($1),($2)])
73     rotate([0,0,($3)])
74     mirror([($4),0,0])
75     BoxPart_Extrude_$5($6, $7)') m4_dnl
76
77 boxpart_d = 0.01;
78
79 m4_dnl BoxPart_Extrude_Linear(dist, `profile(...);');
80 m4_define(`BoxPart_Extrude_Linear',`
81   rotate([90,0,0])
82     translate([0,0, -($1)])
83     linear_extrude(height= boxpart_d + ($1)) {
84       $2
85     }
86 ')
87
88 m4_dnl BoxPart_Extrude_Arc(outer_radius, swept_angle, `profile(...);')
89 m4_dnl  arc starting at transl_x, transl_y, moving towards positive
90 m4_dnl  y at first and then bending towards positive x, until
91 m4_dnl  swept_angle is reached
92 m4_define(`BoxPart_Extrude_Arc',`
93   translate([+($1),0,0])
94     rotate_extrude(angle=($2), convexity=10, $fs=1, $fn=36)
95     translate([-($1),0,0]) {
96       $3
97     }
98 ')
99
100 ts_xbox_lin = ts_xbox - ts_cnrrad*2;
101 ts_ybox_lin = ts_ybox - ts_cnrrad*2;
102
103 m4_dnl TestSealDoBoxShape(`profile(profileargs)');
104 m4_define(`TestSealDoBoxShape',`
105   Box_Part(0,               ts_cnrrad,    0,0, Linear,`ts_ybox_lin', `$1' )
106   Box_Part(0, ts_ybox-ts_cnrrad,          0,0, Arc,`ts_cnrrad,90'  , `$1' )
107   Box_Part(ts_cnrrad,       ts_ybox,    -90,0, Linear,`ts_xbox_lin', `$1' )
108   Box_Part(ts_xbox-ts_cnrrad, ts_ybox,  -90,0, Arc,`ts_cnrrad,90'  , `$1' )
109   Box_Part(ts_xbox, ts_ybox-ts_cnrrad, -180,0, Linear,`ts_ybox_lin', `$1' )
110   Box_Part(ts_xbox,         ts_cnrrad, -180,0, Arc,`ts_cnrrad,90'  , `$1' )
111   Box_Part(ts_xbox-ts_cnrrad, 0,       -270,0, Linear,`ts_xbox_lin', `$1' )
112   Box_Part(ts_cnrrad,         0,       -270,0, Arc,`ts_cnrrad,90'  , `$1' )
113 ')
114
115 m4_dnl '
116
117 module TestSealWallProfile(){
118   z = ts_zbox - ts_innertube - wallthick/2;
119   translate([0, -0.1]) square([wallthick, z]);
120   translate([wallthick/2, z]) circle(r = wallthick/2, $fn=20);
121 }
122
123 module TestSealBox(){
124   TestSealDoBoxShape(`TestSealWallProfile();');
125 }
126
127 //TestWall();
128 //TestSealWallProfile();
129 TestSealBox();
130