8.3 Scale
The scale transformation increases or decreases the dimension of an entity without changing its shape. This operation is also called homothety. Although it is conceivable to have a scale operation that modifies each dimension independently, it is more usual to employ a uniform scale that modifies simultaneously the three dimensions, affecting them with the same factor. If the factor is bigger than one, the size increases. If the fact is smaller than one, the size decreases.
In the case of Khepri, only a uniform scale operation is provided, given by the scale function.
The scale transformation, besides changing the object’s dimension, can also change its position. If that is not the intended case, we can previously apply a translation to center the object in the origin, then apply the scale operation and finally apply the inverse translation to return the object to its original position.
By using the scale operation, it is possible to further simplify the previous definition of the papal cross. In fact, because the cross dimension depends only on the radius, we can arbitrate a unit radius which we can later change through a scale operation. That way, we can write:
papal_cross() =
union(cylinder(u0(), 1, 20),
cylinder(xz(-7, 9), 1, xz(7, 9)),
cylinder(xz(-5, 13), 1, xz(5, 13)),
cylinder(xz(-3, 17), 1, xz(3, 17)))
If we want to build a papal cross with a determined radius \(r\), for example, \(r=3\), we only need to write:
scale(papal_cross(), 3)