On this page:
3.9.1 Predefined Solids
3.9.2 Exercises 16
3.9.2.1 Question 46
3.9.2.2 Question 47
3.9.3 Exercises 17
3.9.3.1 Question 48
3.9.3.2 Question 49
3.9.3.3 Question 50
3.9.3.4 Question 51
3.9.3.5 Question 52

3.9 Three-dimensional Modeling

As we have seen in the section Bi-dimensional Drawing, Khepri provides a set of operations (lines, rectangles, circles, etc.) that allow us to easily draw bi-dimensional representations of objects, such as floor plans, elevations, cross sections, etc.

Although until this moment we have only used Khepri’s bi-dimensional drawing capacities, we now will explore three-dimensional modeling. This type of modeling represents lines, surfaces and solids in the three-dimensional space.

In this section, we will address the Khepri’s functions that allow the creation of such three-dimensional objects.

3.9.1 Predefined Solids

Khepri provides a set of predefined functions that create solids from their three-dimensional coordinates. Although these predefined functions only allow the creation of a limited set of solids, they are enough to create sophisticated models.

The predefined operations can create boxes (function box), cylinders (function cylinder), cones (function cone), spheres (function sphere), tori (function torus), and pyramids (function regular_pyramid), among others. Each of these functions accepts various optional arguments for creating these solids in different ways. This figure shows a set of solids built from the following expressions:

box(xyz(2, 1, 1), xyz(3, 4, 5))

cone(xyz(6, 0, 0), 1, xyz(8, 1, 5))

cone_frustum(xyz(11, 1, 0), 2, xyz(10, 0, 5), 1)

sphere(xyz(8, 4, 5), 2)

cylinder(xyz(8, 7, 0), 1, xyz(6, 8, 7))

regular_pyramid(5, xyz(-2, 1, 0), 1, 0, xyz(2, 7, 7))

torus(xyz(14, 6, 5), 2, 1)

Primitive solids in Khepri.

image

It is interesting to notice that some of the most important works in architectural history can be roughly modeled using these operations. One example is the Great Pyramid of Giza, pictured in this figure, which was built over forty-five centuries ago and is an almost perfect example of a square pyramid. In its original form, it is believed that the Great Pyramid had a squared base, measuring 230 meters on each side, and with a height of 147 meters (making it the tallest man-made structure up until the construction of the Eiffel Tower). Many other Egyptian pyramids have similar proportions, making them easy to model with the following function:

egyptian_pyramid(p, side, height) =

  regular_pyramid(4, p, side/2, 0, height, false)

The case of the Great Pyramid of Giza would be:

egyptian_pyramid(xyz(0, 0, 0), 230, 147)

Great Pyramid of Giza. Photograph by Nina Aldin Thune.

image

Contrary to the Great Pyramid of Giza, there are not many architectural examples that can be modeled with a single geometric primitive. It is, however, possible to create more complex structures by combining several of these primitives.

Take for example the cross in this figure, which was built using six identical truncated cones with their bases placed at the same point, and the top vertices positioned on orthogonal axes.

A cross made of overlapping truncated cones.

image

To model this solid, we will parametrize the base point \(P\) and the cone’s dimensions: the base radius \(r_b\), the top radius \(r_t\) and the length \(l\):

cross(p, rb, rt, l) =

  begin

    cone_frustum(p, rb, p+vx(l), rt)

    cone_frustum(p, rb, p+vy(l), rt)

    cone_frustum(p, rb, p+vz(l), rt)

    cone_frustum(p, rb, p+vx(-l), rt)

    cone_frustum(p, rb, p+vy(-l), rt)

    cone_frustum(p, rb, p+vz(-l), rt)

  end

3.9.2 Exercises 16
3.9.2.1 Question 46

Using the function cross, determine approximate values for the parameters to create the following models:

image image

3.9.2.2 Question 47

Using the function cone_frustum, define the function hourglass that, given the hourglass’ base center point, the base radius, the neck radius and the height, creates a model similar to the following example:

image

Similarly to the truncated cone, we have the truncated pyramid. A truncated pyramid can be created using the function regular_pyramid_frustum. For that, we must specify the number of sides, the base center point, the base radius, the base rotation angle, the top center point (or the height), the top radius, and a boolean that indicates whether the radii refer to circles that inscribe or circumscribe the base/top edges.

In this figure we can see the effect of the rotation angle. The truncated pyramids were generated by the expressions shown below.

Three truncated pyramids with different rotation angles. The angles are, from left to right: \(0\), \(\frac{\pi}{4}\) and \(\frac{\pi}{2}\).

image

regular_pyramid_frustum(3, xyz(0, 0, 0), 2, 0, xyz(0, 0, 1), 1)

regular_pyramid_frustum(3, xyz(8, 0, 0), 2, pi/4, xyz(8, 0, 1), 1)

regular_pyramid_frustum(3, xyz(16, 0, 0), 2, pi/2, xyz(16, 0, 1), 1)

For an architectural example, let us consider the Bent Pyramid, illustrated in this figure, which is characterized for having sloped edges whose angle abruptly change from about \(43^{\circ}\) to \(55^{\circ}\), presumably to avoid its collapse due to the high initial slope. This pyramid is \(188.6\) meters wide and \(101.1\) meters tall, and it can be decomposed into two geometric shapes: an initial truncated square pyramid on top of which stands a square pyramid.

The Bent Pyramid. Photograph by Ivrienen.

image

In order to generalize the modeling of this type of pyramid, we can consider the drawing illustrated in this figure, which represents a section of the pyramid. From this scheme, it is easy to see that \(h_0 + h_1 = h\) and that \(l_0+l_1=l\). Moreover, we have:

\[\tan\alpha_0=\frac{h_0}{l_0}\qquad\qquad \tan\alpha_1=\frac{h_1}{l_1}\]

As a result, we have

\[l_0=\frac{h-l\tan\alpha_1}{\tan\alpha_0-\tan\alpha_1}\]

Section of a bent pyramid.

image

Translating these functions into Julia we obtain:

bent_pyramid(p, l, h, a0, a1) =

  let l0 = (h-l*tan(a1))/(tan(a0)-tan(a1)),

      l1 = l-l0,

      h0 = l0*tan(a0),

      h1 = h-h0

    regular_pyramid_frustum(4, p, l, 0, h0, l1)

    regular_pyramid(4, p+vz(h0), l1, 0, h1)

  end

The rightmost model in this figure shows the Bent Pyramid created by the following expression:

bent_pyramid(xyz(0, 0, 0),

             186.6/2,

             101.1,

             radians_from_degrees(55),

             radians_from_degrees(43))

In the same image, on the left, two other pyramids are visible, which were created by the following expressions:

bent_pyramid(xyz(300, 0, 0),

             186.6/2,

             101.1,

             radians_from_degrees(75),

             radians_from_degrees(40))

bent_pyramid(xyz(600, 0, 0),

             186.6/2,

             101.1,

             radians_from_degrees(95),

             radians_from_degrees(37))

Three different bent pyramids.

image

3.9.3 Exercises 17
3.9.3.1 Question 48

An obelisk is a monument shaped like a bent pyramid. The Washington Monument, visible in this figure, is a modern example of an obelisk of enormous size, which can be defined (relative to this figure) with a truncated pyramid that is \(2l=16.8\) meters wide on the bottom and \(2l_1=10.5\) meters wide on the top, with a total height of \(h=169.3\) meters and an upper pyramid height of \(h_1=16.9\) meters.

Washington Monument. Photograph by David Iliff.

image

Define the obelisk function that, given the base center point, base length, total height, top length, and upper pyramid height, creates an obelisk.

Test the obelisk function by generating the Washington Monument.

3.9.3.2 Question 49

A perfect obelisk follows a set of proportions in which the height of the upper pyramid is equal to the obelisk’s base length, which in turn is one-tenth of the total height. The top length has to be two-thirds of the base length. With these proportions in mind, define the perfect_obelisk function that, given a base center point and the total height, creates a perfect obelisk.

3.9.3.3 Question 50

Using the regular_pyramid_frustum function, define a function called prism that creates a regular prism. The function should receive as parameters the number of sides, the three-dimensional coordinates of the base’s center point, the distance between that center point to each base vertex, the base rotation angle and the three-dimensional coordinates of the top’s center point. As examples consider the following expressions:

prism(3, xyz(0, 0, 0), 0.4, 0, xyz(0, 0, 5))

prism(5, xyz(-2, 0, 0), 0.4, 0, xyz(-1, 1, 5))

prism(4, xyz(0, 2, 0), 0.4, 0, xyz(1, 1, 5))

prism(6, xyz(2, 0, 0), 0.4, 0, xyz(1, -1, 5))

prism(7, xyz(0, -2, 0), 0.4, 0, xyz(-1, -1, 5))

which produce the following image:

image

3.9.3.4 Question 51

The Sears Tower shown in this figure (today called Willis Tower) was for many years the tallest building in the world.

The Sears Tower, in Chicago.

image

This tower consists of nine square prisms connected to each other, with different heights \(h_{i,j}\). From a top view, these nine blocks define a square with a side \(l\), as shown in the following sketch:

image

Using the function prism defined in the previous exercise, define a function called sears_tower capable of creating buildings similar to the Sears Tower. The function should have as parameters the three-dimensional coordinates of the base corner \(P\), the base length \(l\), and nine more parameters relative to each height value \(h_{0,0}, h_{0,1},\ldots,h_{2,2}\).

Generate the Sears Tower, which has the following parameters: \(l=68.7 m\), \(h_{0,1}=h_{1,1}=442 m\), \(h_{1,0}=h_{2,1}=h_{1,2}=368 m\), \(h_{0,0}=h_{2,2}=270 m\) and \(h_{0,2}=h_{2,0}=205 m\), as shown in the following image:

image

Besides the already presented geometrical primitives, there is another that allows the creation of cuboids, i.e., solids with six faces but with a shape that is not necessarily cubic. A cuboid is defined by its eight vertices: the first four are the base vertices and the last four are the top vertices (described in counterclockwise order). The following expressions produce the three cuboids presented in this figure:

Three cuboids with different vertices.

image

cuboid(xyz(0, 0, 0),

       xyz(2, 0, 0),

       xyz(2, 2, 0),

       xyz(0, 2, 0),

       xyz(0, 0, 2),

       xyz(2, 0, 2),

       xyz(2, 2, 2),

       xyz(0, 2, 2))

cuboid(xyz(4, 0, 0),

       xyz(5, 0, 0),

       xyz(5, 2, 0),

       xyz(4, 2, 0),

       xyz(3, 1, 2),

       xyz(5, 1, 2),

       xyz(5, 2, 2),

       xyz(3, 2, 2))

cuboid(xyz(7, 2, 0),

       xyz(8, 0, 0),

       xyz(8, 3, 0),

       xyz(6, 3, 0),

       xyz(7, 2, 2),

       xyz(8, 0, 2),

       xyz(8, 3, 2),

       xyz(6, 3, 2))

The John Hancock Center, illustrated in this figure, is a good example of a building with a geometry that can be modeled with a cuboid. In fact, this building has a tapered shape with a regular base and top.

The John Hancock Center, in Chicago. Photograph by Cacophony.

image

To model it, we can start by defining the regular_cuboid function, parametrized by the base center point \(P\), the base length \(l_b\) and width \(w_b\), the top base length \(l_t\) and width \(w_t\), and, finally, the height \(h\). For creating the solid, the cuboid function becomes particularly useful, leaving us only with the task of determining the position of each vertex relative to the base point \(P\).

regular_cuboid(p, lb, wb, lt, wt, h) =

  cuboid(p+vxyz(-(lb/2), -(wb/2), 0),

         p+vxyz(lb/2, -(wb/2), 0),

         p+vxyz(lb/2, wb/2, 0),

         p+vxyz(-(lb/2), wb/2, 0),

         p+vxyz(-(lt/2), -(wt/2), h),

         p+vxyz(lt/2, -(wt/2), h),

         p+vxyz(lt/2, wt/2, h),

         p+vxyz(-(lt/2), wt/2, h))

Using this function, it becomes trivial to create buildings inspired by the shape of the John Hancock Center, as presented in this figure.

Buildings inspired by John Hancock Center’s cuboid geometry.

image

3.9.3.5 Question 52

A pylon is a distinctive Egyptian architectural element, illustrated in this figure. It is a monumental gateway enclosed by two identical tapering towers on both sides. Each tower is cuboid-shaped, with a rectangular base and top and trapezoidal sides.

Pylons of the Karnak Temple. Illustration by Albert Henry Payne.

image

Define a conveniently parametrized function capable of creating a simplified version of a pylon similar to the one shown in the following image:

image