chiark / gitweb /
osstest-arm-net-bracket: add hstreng
[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
37 $fa=2;
38 $fs=0.2;
39
40 module SegmentBasisSquare(zmin, zmax, xmin){
41   translate([xmin, zmin-d]) square([-xmin+d, zmax-zmin+d*2]);
42 }
43 module ConvexSegment(xc, zc, r, zmin, zmax){
44   intersection(){
45     translate([xc,zc]) circle(r=r);
46     SegmentBasisSquare(zmin,zmax,-50);
47   }
48 }
49 module ConcaveSegment(xc, zc, r, zmin, zmax){
50   difference(){
51     SegmentBasisSquare(zmin,zmax, xc);
52     translate([xc,zc]) circle(r=r);
53   }
54 }
55
56 module PawnTemplate(){
57   ConvexSegment(  x1 + r1,  z1,   r1, z1, 50);
58   ConvexSegment(  x1 + r2,  z1,   r2, z2, z1);
59   ConcaveSegment( x3 - r3,  z3,   r3, z3, z2);
60   ConcaveSegment( x3 - r4,  z3,   r4, z4, z3);
61   ConvexSegment(  xc5,      zc5,  r5, z5, z4);
62   polygon([[x6, z6],
63            [x5, z5+d],
64            [d, z5+d],
65            [d, z6]]);
66 }
67
68 module Pawn(h=htotal){
69   scale(h/htotal) {
70     rotate_extrude(convexity=10, $fn=50){
71       assign($fn=undef){
72         PawnTemplate();
73       }
74     }
75   }
76 }
77
78 Pawn(h=30);
79 //PawnTemplate();