On this page:
7.1.1 Exercises 33
7.1.1.1 Question 116
7.1.1.2 Question 117
7.1.1.3 Question 118
7.1.1.4 Question 119
7.1.1.5 Question 120

7.1 Constructive Solid Geometry

Constructive solid geometry is one of the most common techniques used for modeling solids. This approach is based on the combination of simple solids, such as parallelepipeds, spheres, pyramids, cylinders, tori, etc. Each of these solids can be seen as a set of points in space, and their combination is achieved by using set operations such as union, intersection, and subtraction of those sets of points. To simplify, we will refer to the set of points in space as a region.

Let us start by considering the union operation. Given the regions \(R_0\) and \(R_1\), their union \(R_0\cup R_1\) corresponds to the set of points that belongs to \(R_0\), \(R_1\), or both \(R_0\) and \(R_1\). This operation is implemented in Khepri by the union function. This figure shows, on the left side, the union between a cube and a sphere, produced by the following expression:

let cube = box(xyz(0, 0, 0), xyz(1, 1, 1)),

    sphere = sphere(xyz(0, 1, 1), 0.5)

  union(cube, sphere)

end

Another operation is the intersection of regions \(R_0\cap R_1\), which produces the group of points that belong simultaneously to both sets \(R_0\) and \(R_1\). In Khepri, this operation is implemented by the intersection function. This figure shows, on the center, an intersection between a cube and a sphere, which was produced by the following expression:

let cube = box(xyz(2, 0, 0), xyz(3, 1, 1)),

    sphere = sphere(xyz(2, 1, 1), 0.5)

  intersection(cube, sphere)

end

Finally, there is also the operation of subtraction of regions \(R_0\setminus R_1\) which corresponds to the group of points that belongs to \(R_0\) but do not belong to \(R_1\). Contrary the previous ones, this operation is not commutative. Thus, subtracting a sphere from a cube is different from subtracting a cube from a sphere. This difference is visible in the two volumes on the right side of this figure, which were produced by the expressions:

let cube = box(xyz(4, 0, 0), xyz(5, 1, 1)),

    sphere = sphere(xyz(4, 1, 1), 0.5)

  subtraction(cube, sphere)

end

and

let cube = box(xyz(6, 0, 0), xyz(7, 1, 1)),

    sphere = sphere(xyz(6, 1, 1), 0.5)

  subtraction(sphere, cube)

end

Combination of solids: union of a cube with a sphere (on the left), intersection of a cube with a sphere (on the center), and subtraction between a cube and a sphere and vice-versa (on the right).

image

Like other previously discussed functions, such as line and spline, the functions union, intersection, and subtraction receive any number of arguments or, alternatively, an array with all the arguments. As an example, consider three cylinders placed along the \(X\), \(Y\) and \(Z\) axes. The union of these cylinders is visible on the left side of this figure and was generated by the expression:

union(

    cylinder(xyz(-1, 0, 0), 1, xyz(1, 0, 0)),

    cylinder(xyz(0, -1, 0), 1, xyz(0, 1, 0)),

    cylinder(xyz(0, 0, -1), 1, xyz(0, 0, 1)))

This object has the interesting feature that its shadow, on the bottom, back, and side planes, is a square. On the right side of the same figure we have an even more interesting solid, generated by the intersection of the same three cylinders, producing an object that, despite not being a sphere, has a circular shadow on the bottom, back, and side planes.

The union and intersection of three cylinders orthogonally arranged.

image

To understand the difference between this object and a real sphere, we can subtract a sphere from the object. To be able to "peek" inside of the object, we will subtract a sphere with a slightly bigger radius than the cylinders:

subtraction(

    intersection(

        cylinder(xyz(-1, 0, 0), 1, xyz(1, 0, 0)),

        cylinder(xyz(0, -1, 0), 1, xyz(0, 1, 0)),

        cylinder(xyz(0, 0, -1), 1, xyz(0, 0, 1))),

    sphere(xyz(0, 0, 0), 1.01))

The result is presented in this figure.

Subtraction of a sphere from the intersection of three cylinders orthogonally arranged. The sphere has a radius \(1\%\) bigger than the one of the cylinders so that we can view the inside.

image

7.1.1 Exercises 33
7.1.1.1 Question 116

Model a stone sink identical to the one presented in the following image:

image

The parameters relevant for the sink are illustrated in the section views and top view presented in the following image:

image

Define a function called sink that builds a sink identical to the one on the previous image.

7.1.1.2 Question 117

Imagine a stone bathtub identical to the one presented in the following image:

image

The parameters relevant for the bathtub are described in the section views and top view presented in the following image:

image

Define a function named bathtub that builds a bathtub identical to the one on the previous image.

7.1.1.3 Question 118

Consider the following image:

image

The image represents a shelter with a cuboid shape and built with round tubes cut in a way that the interior space has the shape of a quarter of a sphere. Note that the tubes’ thickness is \(10\%\) of their radius. Also note the relation between the radius of the quarter of sphere and that of the cylinders.

Define a function that builds the shelter from the center of the sphere, the height of the cuboid, and the number of tubes to place along the height.

7.1.1.4 Question 119

Redo the previous exercise, but now considering the orientation of the tubes visible in the following image:

image

7.1.1.5 Question 120

Redo the previous exercise, but now considering the orientation of the tubes as seen in the following image:

image