chiark / gitweb /
fairphone-case: wip ButtonCoverReinf
[reprap-play.git] / pawn.scad
1 // -*- C -*-
2
3 // shape parameters
4
5 r1 =  2.85;
6 r2 =  4; a2 = 27;
7 r3 = r2;
8 r4 =  4; a4 = 18;
9 r5 = 30;
10 h6 = 7; a6 = 4;
11
12 // coordinates
13
14                                 z1 =  0;
15 h2 = r2 * sin(a2);              z2 = z1 - h2;
16 h3 = r3 * sin(a2);              z3 = z2 - h3;
17 h4 = r4 * sin(a4);              z4 = z3 - h4;
18
19 zc5 = z4 - r5 * sin(a4);
20 z5 = zc5 + r5 * sin(a6);        z6 = z5 - h6;
21
22 x1 =  0 - r1;
23 x2 = x1 + r2 * (1-cos(a2));
24 x3 = x2 + r3 * (1-cos(a2));
25 x4 = x3 - r4 * (1-cos(a4));
26
27 xc5 = x4 + r5 * cos(a4);
28 x5 = xc5 - r5 * cos(a6);
29
30 x6 = x5 - h6 * tan(a6);
31
32 htotal = r1 - z6;
33 echo("height", htotal);
34
35 d = 0.01;
36 dx = 0.00;
37
38 $fa=2;
39 $fs=0.2;
40
41 module SegmentBasisSquare(zmin, zmax, xmin){
42   translate([xmin, zmin-d]) square([-xmin+dx, zmax-zmin+d*2]);
43 }
44 module ConvexSegment(xc, zc, r, zmin, zmax){
45   intersection(){
46     translate([xc,zc]) circle(r=r);
47     SegmentBasisSquare(zmin,zmax,-50);
48   }
49 }
50 module ConcaveSegment(xc, zc, r, zmin, zmax){
51   difference(){
52     SegmentBasisSquare(zmin,zmax, xc);
53     translate([xc,zc]) circle(r=r);
54   }
55 }
56
57 module PawnTemplate(){
58   ConvexSegment(  x1 + r1,  z1,   r1, z1, 50);
59   ConvexSegment(  x1 + r2,  z1,   r2, z2, z1);
60   ConcaveSegment( x3 - r3,  z3,   r3, z3, z2);
61   ConcaveSegment( x3 - r4,  z3,   r4, z4, z3);
62   ConvexSegment(  xc5,      zc5,  r5, z5, z4);
63   polygon([[x6, z6],
64            [x5, z5+d],
65            [dx, z5+d],
66            [dx, z6]]);
67 }
68
69 module Pawn(h=htotal){
70   scale(h/htotal) {
71     rotate_extrude(convexity=10, $fn=50){
72       assign($fn=undef){
73         PawnTemplate();
74       }
75     }
76   }
77 }
78
79 Pawn(h=30);
80 //PawnTemplate();