Now, we will use HyperFun to construct objects using set-theoretic operations, which were introduced in the previous section. If you do not understand the meaning of a term (union, intersection, subtraction), please refer to the previous pages.

STEP 1: First, let’s try to display a cube 10 in length.

my_model(x[3], a[1]) { array box_vertex[3]; box_vertex[1] = 0.0; box_vertex[2] = 0.0; box_vertex[3] = 0.0; box = hfBlock(x, box_vertex, 10.0, 10.0, 10.0); my_model = box; }

Second, let’s try to polygonize and set the bounding box larger than the object in the form “-b 12” for example.

hfp set.hf -b 12

STEP 2: Please translate the center of the cube to the origin. When you finish, polygonize using the command in Step 1.

my_model(x[3], a[1]) { array box_vertex[3]; box_vertex[1] = -5.0; box_vertex[2] = -5.0; box_vertex[3] = -5.0; box = hfBlock(x, box_vertex, 10.0, 10.0, 10.0); my_model = box; }

STEP 3: Let’s try to make a sphere which has its center as the origin and a radius of 6.2. First, to display the sphere only, please type *my_model = sphere*

my_model(x[3], a[1]) { array box_vertex[3]; array sphere_center[3]; box_vertex[1] = -5.0; box_vertex[2] = -5.0; box_vertex[3] = -5.0; box = hfBlock(x, box_vertex, 10.0, 10.0, 10.0); sphere_center[1] = 0.0; sphere_center[2] = 0.0; sphere_center[3] = 0.0; sphere = hfSphere(x, sphere_center, 6.2); my_model = sphere; }

STEP 4: We will get the union of a box and a sphere. In HyperFun, set-theoretic union operator is |.

my_model(x[3], a[1]) { array box_vertex[3]; array sphere_center[3]; box_vertex[1] = -5.0; box_vertex[2] = -5.0; box_vertex[3] = -5.0; box = hfBlock(x, box_vertex, 10.0, 10.0, 10.0); sphere_center[1] = 0.0; sphere_center[2] = 0.0; sphere_center[3] = 0.0; sphere = hfSphere(x, sphere_center, 6.2); my_model = box | sphere; }

STEP 5: We will get the intersection of a box and a sphere. In HyperFun, set-theoretic intersection operator is &.

my_model(x[3], a[1]) { array box_vertex[3]; array sphere_center[3]; box_vertex[1] = -5.0; box_vertex[2] = -5.0; box_vertex[3] = -5.0; box = hfBlock(x, box_vertex, 10.0, 10.0, 10.0); sphere_center[1] = 0.0; sphere_center[2] = 0.0; sphere_center[3] = 0.0; sphere = hfSphere(x, sphere_center, 6.2); my_model = box & sphere; }

STEP 6: We will subtract the sphere from the box. In HyperFun, set-theoretic subtraction operator is \.

my_model(x[3], a[1]) { array box_vertex[3]; array sphere_center[3]; box_vertex[1] = -5.0; box_vertex[2] = -5.0; box_vertex[3] = -5.0; box = hfBlock(x, box_vertex, 10.0, 10.0, 10.0); sphere_center[1] = 0.0; sphere_center[2] = 0.0; sphere_center[3] = 0.0; sphere = hfSphere(x, sphere_center, 6.2); my_model = box \ sphere; }

STEP 7: Subtraction of the box from the sphere.

my_model(x[3], a[1]) { array box_vertex[3]; array sphere_center[3]; box_vertex[1] = -5.0; box_vertex[2] = -5.0; box_vertex[3] = -5.0; box = hfBlock(x, box_vertex, 10.0, 10.0, 10.0); sphere_center[1] = 0.0; sphere_center[2] = 0.0; sphere_center[3] = 0.0; sphere = hfSphere(x, sphere_center, 6.2); my_model = sphere \ box; }