Finish set operation
----------------------------------------------------------
my_model(x[3], a[1])
{
array center[3];
array vertex[3];
center = [0, 0, 0]; --球の中心座標
vertex = [-2, -2, -2]; --箱の角の座標
kyu = hfSphere(x, center, 2.5);
--centerを中心とする半径2.5の球
hako = hfBlock(x, vertex, 4, 4, 4);
--それぞれの辺の長さが4の箱
my_model = kyu ;
}
Modeling a complex constructive solid
(modeling space [-10,10] for all coordinates)
solid(x[3], a[1])
{
array center[3];
-- box
xx = (x[1]+7) & (7-x[1]);
yy = (x[2]+7) & (7-x[2]);
zz = (x[3]+7) & (7-x[3]);
box = xx & yy & zz;
-- cylinder
center=[0,0,0];
cyl = hfCylinderY(x,center,4) & (x[2]+9) & (9-x[2]);
-- holes
hole1 = hfCylinderY(x,center,2.5);
hole2 = hfCylinderZ(x,center,5);
-- final solid using constructive operations
solid = box | cyl \ hole1 \ hole2;
}
The bunny
----------------------------------------------------------
usagi(x[3], a[1])
{
array c1[3], c2[3], c3[3], c4[3], c5[3];
c1 = [0, -2, 0];
c2 = [2, -2, 2];
c3 = [-2, -2, 2];
c4 = [2, 2, 0];
c5 = [-2, 2, 0];
head = hfSphere(x, c1, 3);
eye1 = hfSphere(x, c2, 0.5);
eye2 = hfSphere(x, c3, 0.5);
ear1 = hfEllipsoid(x, c4, 1,2,1);
ear2 = hfEllipsoid(x, c5, 1, 2, 1);
usagi = (head | ear1 | ear2) \ (eye1 | eye2);
}
----------------------------------------------------------