$fn=32; PawnRadius=12; PawnHeight=5; PawnFilet=1.5; BumpRadius=0.7; //********************************************** //**** RoundedCylinder(Radius,Height,Filet) **** //********************************************** //!!! BEWARE, VARIABLES CANNOT BE MODIFIED DURING RUN TIME! // VARIABLES ARE EFFECTIVELY CONSTANTS THAT DO NOT CHANGE. module RoundedCylinder(Radius,Height,Filet) { //length=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); union() { cylinder(Height,Radius-Filet,Radius-Filet,center=true); cylinder(Height-2*Filet,Radius,Radius,center=true); translate([0,0,Height/2-Filet]) rotate_extrude(convexity = 2) //the ray hits at most twice a front face translate([Radius-Filet, 0, 0]) circle(r = Filet); translate([0,0,-(Height/2-Filet)]) rotate_extrude(convexity = 2) translate([Radius-Filet, 0, 0]) circle(r = Filet); } } module HalfRoundedCylinderTop(Radius,Height,Filet) { difference() { RoundedCylinder(Radius,Height,Filet); translate([0,0,-(Radius+1)/2]) cylinder(Radius+1,Radius+1,Radius+1,center=true); } } module HalfRoundedCylinderBottom(Radius,Height,Filet) { difference() { RoundedCylinder(Radius,Height,Filet); translate([0,0,(Radius+1)/2]) cylinder(Radius+1,Radius+1,Radius+1,center=true); } } //******************** //**** HalfSphere **** //******************** module HalfSphereTop(Radius) { difference() { sphere(Radius); translate([0,0,-(Radius+1)/2]) cylinder(Radius+1,Radius+1,Radius+1,center=true); } } module HalfSphereBottom(Radius) { difference() { sphere(Radius); translate([0,0,(Radius+1)/2]) cylinder(Radius+1,Radius+1,Radius+1,center=true); } } //****************************************** //**** RoundedCylinderZ(x1,y1,x2,y2,r0) **** //****************************************** //On the Z=0 plane //!!! BEWARE, VARIABLES CANNOT BE MODIFIED DURING RUN TIME! // VARIABLES ARE EFFECTIVELY CONSTANTS THAT DO NOT CHANGE. module RoundedCylinderZ(x1,y1,x2,y2,r0) { length=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); union() { translate([x1,y1,0]) sphere(r0); translate([x2,y2,0]) sphere(r0); if(x2==x1) { translate ([x1,y1,0]) rotate([-90,0,0]) cylinder(length,r0,r0); } else { alpha=atan((x2-x1)/(y2-y1)); if(y2-y1<0) { translate ([x1,y1,0]) rotate([0,0,-alpha-180]) rotate([-90,0,0]) cylinder(length,r0,r0); } else { translate ([x1,y1,0]) rotate([0,0,-alpha]) rotate([-90,0,0]) cylinder(length,r0,r0); } } } } //************************************************ //**** RoundedAxialRectangleZ(x1,y1,x2,y2,r0) **** //************************************************ //uses RoundedCylinderZ module RoundedAxialRectangleZ(x1,y1,x2,y2,r0) { union() { RoundedCylinderZ(x1,y1,x2,y1,r0); RoundedCylinderZ(x1,y2,x2,y2,r0); RoundedCylinderZ(x1,y1,x1,y2,r0); RoundedCylinderZ(x2,y1,x2,y2,r0); translate([x1,y1,-r0]) cube([x2-x1,y2-y1,2*r0]); } } //*************** //**** **** //**** PAWNS **** //**** **** //*************** module Pawn_Simple() { RoundedCylinder(PawnRadius,PawnHeight,PawnFilet); } module Pawn_Bumps() { union() { RoundedCylinder(PawnRadius,PawnHeight,PawnFilet); for(i=[0:18:342]) { rotate([0,0,i]) translate([PawnRadius-PawnFilet-2*BumpRadius,0,PawnHeight/2]) sphere(BumpRadius); } } } module Pawn_Pyramid() { union() { RoundedCylinder(PawnRadius,PawnHeight,PawnFilet); translate([0,0,1]) RoundedCylinder(PawnRadius-2,PawnHeight+1,PawnFilet); translate([0,0,2]) RoundedCylinder(PawnRadius-4,PawnHeight+2,PawnFilet); translate([0,0,3]) RoundedCylinder(PawnRadius-6,PawnHeight+3,PawnFilet); translate([0,0,4]) RoundedCylinder(PawnRadius-8,PawnHeight+4,PawnFilet); } } module Pawn_HalfEllipse() { union() { scale([1,1,0.7]) HalfSphereTop(PawnRadius); HalfRoundedCylinderBottom(PawnRadius,PawnHeight,PawnFilet); } } module Board5x5() { difference() { union() { RoundedAxialRectangleZ(-5,-5,2*5*(PawnRadius+1)+5,2*5*(PawnRadius+1)+5,PawnHeight/2); for(x=[0:5]) { color("red") translate([0,0,PawnHeight/2]) RoundedAxialRectangleZ(x*2*(PawnRadius+1),0,x*2*(PawnRadius+1),5*2*(PawnRadius+1),0.7); } for(y=[0:5]) { color("red") translate([0,0,PawnHeight/2]) RoundedAxialRectangleZ(0,y*2*(PawnRadius+1),5*2*(PawnRadius+1),y*2*(PawnRadius+1),0.7); } } union() { for(x=[0:4]) { for(y=[0:4]) { translate([PawnRadius+1+x*2*(PawnRadius+1),PawnRadius+1+y*2*(PawnRadius+1),PawnHeight/2]) RoundedCylinder(PawnRadius+0.1,PawnHeight,PawnFilet); } } } } } Board5x5(); translate([0,-2*PawnRadius,0]) Pawn_Simple(); translate([3*PawnRadius,-2*PawnRadius,0]) Pawn_Bumps(); translate([6*PawnRadius,-2*PawnRadius,0]) Pawn_Pyramid(); translate([9*PawnRadius,-2*PawnRadius,0]) Pawn_HalfEllipse();