7.7 Revolutions
A revolution is a surface or solid generated by rotating an object around an axis. A surface of revolution is a surface created by the rotation of a bi-dimensional curve around an axis. A solid of revolution is a solid generated by the rotation of a bi-dimensional region around an axis.
The revolution is a very simple process of creating surfaces and solids, and the Khepri’s function revolve serves exactly that purpose. The function receives the curve or region to revolve and, optionally, a point on the rotation axis (by omission, the origin), a vector parallel to the rotation axis (by omission, the vector with the \(Z\) axis direction), the initial angle of revolution (by omission, zero), and the angle increment for the revolution (by omission, \(2\pi\)). Naturally, if the increment is \(2\pi\) radians, we get a complete revolution.
7.7.1 Surfaces of Revolution
Using the revolve function, it is now easy to create surfaces or solids of revolution. For example, consider the spline presented in this figure, which was created from the following expression:
spline(xyz(0, 0, 2),
xyz(1, 0, -1),
xyz(2, 0, 1),
xyz(3, 0, -1),
xyz(4, 0, 0),
xyz(5, 0, -1))
A spline used as the base to build a surface of revolution.
Note that the spline is located on the \(XZ\) plane and, because of that, it can be used as the base to build a surface with the revolution axis in the \(Z\) axis. To better visualize the interior of the surface, we will consider an opening of \(\frac{2\cdot\pi}{4}\). The corresponding Julia expression is:
revolve(spline(xyz(0, 0, 2),
xyz(1, 0, -1),
xyz(2, 0, 1),
xyz(3, 0, -1),
xyz(4, 0, 0),
xyz(5, 0, -1)),
u0(),
vz(),
1/4*2*pi,
3/4*2*pi)
The result of evaluating the previous expression is represented in this figure.
A surface of revolution generated by the spline represented in this figure.
Surfaces of revolution are often used in architecture, namely, to design domes. The onion-shaped dome, for example, is a widely explored element in Russian and Mughal architectures, among others. The image in this figure shows the domes of Verkho Saviour Cathedral in Moscow, Russia.
Domes of the Verkho Saviour Cathedral in Moscow, Russia. Photograph by Amanda Graham.
Onion-shaped domes possess an axial symmetry that allows them to be modeled as surfaces of revolution. For that, we will define a function called dome that, from an array of coordinates belonging to the dome’s profile, builds the surface of revolution that models the dome. To simplify, we will admit that the dome is closed at the top and that the top corresponds to the first element of the coordinates’ array. This simplification allows us to establish the surface revolution axis from the first element of the coordinates’ array:
dome(pts) =
revolve(spline(pts), pts[1])
To evaluate the function, we can get some coordinates from the profile of real domes and use them to invoke the function. That is precisely what we did in the following expressions:
dome([xyz(0, 0, 12),
xyz(0, 1, 8),
xyz(0, 6, 4),
xyz(0, 6, 2),
xyz(0, 5, 0)])
dome([xyz(15, 0, 9),
xyz(15, 3, 8),
xyz(15, 7, 5),
xyz(15, 8, 3),
xyz(15, 8, 2),
xyz(15, 7, 0)])
dome([xyz(30, 0, 13),
xyz(30, 1, 10),
xyz(30, 5, 7),
xyz(30, 5, 2),
xyz(30, 3, 0)])
which create, from left to right, the surfaces presented in this figure. Note that the dome function creates not only onion domes but also other types of domes.
Domes generated in Khepri.
7.7.2 Exercises 38
7.7.2.1 Question 151
Consider the tube with a sinusoidal profile presented in the following image:
The tube was produced taking into account the geometrical parameters described in the following profile:
Define the function sinusoidal_tube that, from the previously illustrated parameters \(P\), \(r\), \(a\), \(omega\), \(lx\), and, finally, from the sinusoid’s phase \(phi\) and the separation between interpolation points \(\Delta_x\), generates the intended sinusoidal tube. For example, the tubes represented in the following image were generated by the evaluation of the following expressions:
sinusoidal_tube(xyz(-20, 80, 0), 20, 2.0, 0.5, 0, 60, 0.2)
sinusoidal_tube(xyz(0, 30, 0), 5, 0.2, 2.0, 0, 60, 0.1)
sinusoidal_tube(xyz(30, 0, 0), 10, 1.0, 1.0, pi/2, 60, 0.2)
7.7.2.2 Question 152
Consider an egg as a generalization of eggs of different proportions, as illustrated in the following image:
The egg’s section is sketched in the following image:
Define an egg function that creates a three-dimensional egg. The function should receive, only, the coordinates of point \(P\), the \(r_0\) and the \(r_1\) radii, and, finally, the height \(h\) of the egg.
7.7.3 Solids of Revolution
If, instead of using a curve to produce a surface of revolution, we use a region, the result will be a solid of revolution. As an example, imagine we use a trefoil to generate an arch. The image on the left of this figure shows the region used in the revolution, and this figure shows the created solid. For this example, we used the following expression:
A solid of revolution generated by the trefoil represented in this figure.
revolve(nfoil(xy(3, 0), 1, 3), u0(), vy(), 0, pi)
Through the combination of extrusions and revolutions, it is possible to produce very sophisticated models. Let us consider, for example, the modeling of an arcade whose columns and arches have sections in the shape of an nfoil. To model these shapes, it is necessary to know the position \(P\) of the center of the foil used to generate the column or the arch, the radius \(r_c\) of the columns and the number of foils \(n_f\) to use. It is also necessary to know the height \(h\) of the columns and the radius \(r_a\) of the arches. The following functions create the column and the arch:
nfoil_column(p, rc, nf, h) = extrusion(nfoil(p, rc, nf), h)
nfoil_arch(p, rc, ra, nf) = revolve(nfoil(p, rc, nf), p+vx(ra), vy(), 0, pi)
To build the arcade, the simplest way is to define a function that builds a column and an arch and that, recursively, builds the remaining arcades until it has no more arcades to build, the case at which it creates the last column that supports the last arch. The translation of this algorithm to Julia is:
nfoil_arcade(p, rc, nf, ra, h, n) =
if n == 0
nfoil_column(p, rc, nf, h)
else
union(nfoil_column(p, rc, nf, h),
nfoil_arch(p+vxyz(0, 0, h), rc, ra, nf),
nfoil_arcade(p+vxyz(2*ra, 0, 0), rc, nf, ra, h, n-1))
end
The image of this figure presents a perspective of a series of arcades generated by the following expressions:
nfoil_arcade(xy(0, 0), 1, 4, 5, 10, 5)
nfoil_arcade(xy(0, 10), 1, 6, 5, 10, 5)
nfoil_arcade(xy(0, 20), 1, 8, 5, 10, 5)
nfoil_arcade(xy(0, 30), 1, 10, 5, 10, 5)
nfoil_arcade(xy(0, 40), 1, 12, 5, 10, 5)
Arcades generated by the nfoil_arcade function. From the front to the back, the arcades have quatrefoil, sexfoil, octofoil, and so on, as section.
7.7.4 Exercises 39
7.7.4.1 Question 153
We want to create a program capable of generating a barrel with the base located on the \(XY\) plane. Consider that the base of the barrel is closed but the top is open.
Create a function called profile_barrel that receives the point \(P\), both radii \(r_0\) and \(r_1\), the height \(h\), and the thickness \(t\), and returns the region that defines the profile of the barrel, as presented in the following image:
7.7.4.2 Question 154
Using the function profile_barrel, define the function barrel that, given the same parameters as the former one, creates a three-dimensional barrel. The function should have the following form:
barrel(p, r0, r1, h, t) = ___
As an example, consider the following image that was generated by the evaluation of the following expressions:
barrel(xyz(0, 0, 0), 1, 1.3, 4, 0.1)
barrel(xyz(4, 0, 0), 1, 1.5, 3, 0.3)
barrel(xyz(8, 0, 0), 1, 0.8, 5, 0.1)
7.7.4.3 Question 155
The barrel function created in the previous exercise is unable to generate the traditional wooden barrels that are built from wooden staves put together next to each other. The following image shows a few examples of these wooden staves, with different dimensions and placements:
Define the function barrel_stave that, besides the same parameters that define a barrel, also receives an initial rotation angle \(\alpha\), which defines where the stave begins, and an angle increment \(\Delta_\alpha\), which corresponds to the angular amplitude of the stave, and builds the three-dimensional section of the barrel corresponding to the stave in question.
7.7.4.4 Question 156
Define a function called barrel_staves that receives as parameters the point \(P\), the radii \(r_0\) and \(r_1\), the height \(h\), the thickness \(t\), the number of staves \(n\), and the angular spacing \(s\) between staves, and creates a three-dimensional barrel with that number of staves. The following image shows some examples of these barrels, which were created by the evaluation of the following expressions:
barrel_staves(xyz(0, 0, 0), 1, 1.3, 4, 0.1, 10, 0.05)
barrel_staves(xyz(4, 0, 0), 1, 1.3, 4, 0.1, 4, 0.5)
barrel_staves(xyz(8, 0, 0), 1, 1.3, 4, 0.1, 20, 0.01)