goban/white_stone.scad

30 lines
1 KiB
OpenSCAD

include <params.scad>
module wstone() {
union() {
x1 = $stone_radius;
y1 = $stone_height*2/5;
x2 = 0;
y2 = 0;
x3 = -$stone_radius;
y3 = $stone_height*2/5;
xc = ((pow(x3, 2)-pow(x2, 2)+pow(y3, 2)-pow(y2, 2))/(2*(y3-y2))-(pow(x2, 2)-pow(x1, 2)+pow(y2, 2)-pow(y1, 2))/(2*(y2-y1)))/((x3-x2)/(y3-y2)-(x2-x1)/(y2-y1));
yc = -(x2-x1)/(y2-y1)*xc+(pow(x2, 2)-pow(x1, 2)+pow(y2, 2)-pow(y1, 2))/(2*(y2-y1));
r = sqrt(pow(x1-xc, 2)+pow(y1-yc, 2));
difference() {
translate([0, 0, r]) sphere(r=r, $fn=200);
translate([-r-1, -r-1, $stone_height*2/5])
cube([r*2+2, r*2+2, r*2+2]);
}
translate([0, 0, $stone_height*2/5])
cylinder(h=2, r=$stone_radius, $fn=200);
translate([0, 0, $stone_height*3/5]) difference() {
translate([0, 0, -r+$stone_height*2/5]) sphere(r=r, $fn=200);
translate([-r-1, -r-1, -r*2-2])
cube([r*2+2, r*2+2, r*2+2]);
}
}
}
wstone();