HyperFun: Sample Model
-
-
--This HyperFun program consists of one object:
--union of superellipsoid, torus and soft object
my_model(x[3], a[1])
{
array x0[9], y0[9], z0[9], d[9], center[3];
x1=x[1];
x2=x[2];
x3=x[3];
-- superellipsoid by formula
superEll = 1-(x1/0.8)^4-(x2/10)^4-(x3/0.8)^4;
-- torus by library function
center = [0, -9, 0];
torus = hfTorusY(x,center,3.5,1);
-- soft object
x0 = [2.,1.4, -1.4, -3, -3, 0, 2.5, 5., 6.5];
y0 = [8, 8, 8, 6.5, 5, 4.5, 3, 2, 1];
z0 = [0, -1.4,-1.4, 0, 3, 4, 2.5, 0, -1];
d = [2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.7, 3];
sum = 0.;
i = 1;
- while (i<10) loop
- xt = x[1] - x0[i];
yt = x[2] - y0[i];
zt = x[3] - z0[i];
r = sqrt(xt*xt+yt*yt+zt*zt);
- if (r <= d[i]) then
- r2 = r*r; r4 = r2*r2; r6 = r4*r2;
d2 = d[i]^2; d4 = d2*d2; d6 = d4*d2;
sum = sum + (1 - 22*r2/(9*d2) +
17*r4/(9*d4) - 4*r6/(9*d6));
- endif;
i = i+1;
- endloop;
soft = sum - 0.2;
-- final model as set-theoretic union
my_model = superEll | torus | soft;
}
|
|
|