Shape Metrics: A Unified Approach to Shape Inversions and Custom Distance Functions
Year: 2020 Authors: Risto A. Paju
Core claim
Shape inversion can be expressed as ordinary inversion in a metric defined by the shape itself, enabling simpler formulas and new non-inversion uses.
Topics
shape inversion, shape metrics, fractal art, Voronoi diagrams, 3D graphics
Domains
metric geometry, Euclidean and non-Euclidean distance, pseudo-metrics, high-dimensional geometry, mathematical art, fractal imagery, generative graphics, visual pattern design
Methods
distance-function reformulation, shape inversion, Voronoi coloring, ray marching
Media
lattice figures, cube and octahedron models, Voronoi diagrams, computer-generated images
Paper text
The text below is the locally extracted OCR/Markdown version of the paper. Raw PDF files remain local and are not published here.
Bridges 2020 Conference Proceedings
Shape Metrics: A Unified Approach to Shape Inversions and Custom Distance Functions
Risto A. Paju http://algoristo.com/ Jyväskylä, Finland; risto.a.paju@iki.fi
Abstract
I present a new approach to shape inversions that provides both computational simplicity and an alternative, unified understanding of the inversion operation. Instead of modifying the circle inversion formula for different shapes, my method changes the metric from Euclidean to a shape-dependent one. As a by-product, I outline a technique to construct new metrics and pseudo-metrics from given shapes, and suggest various non-inversion applications.
(a) Iterated hexagon inversions of an infinite hexagonal lattice
(b) Iterated cube inversions of a central octahedron
Figure 1: Fractal art created with shape inversions using shape metrics
Shape Inversions with a Metric Interpretation
From Apollonius of Perga to today’s fractal programmers, circle inversion remains a fruitful tool for mathematical artists. The inversion of the point by an origin-centred circle of radius is given by
where is the Euclidean distance from to . Gdawiec [3] generalized this to non-circular shapes by replacing the fixed radius with a varying distance :
Paju
Specifically, is the Euclidean distance from to the shape-defining set along the ray from to , i.e. in Figure 2. Note that for to be well-defined, must be a star-shaped set [3] with respect to : it must intersect the ray at exactly one point for each .
Figure 2: Inversion in the square
I was introduced to shape inversions by Gregg Helt [4] and proceeded with my own experiments, resulting in pictures such as Figure 1(a). In order to switch between circles and other shapes more easily, I rewrote (2) as
where
is the shape metric. This retains the original form of circle inversion (1), with the shape information now subsumed into the metric. For circles, , so (3) reverts to (1) as a special case.
The advantages of this definition become clear when we notice that is a familiar metric for many common shapes besides circles. First, recall that the shape is defined by . Setting in (4) we then get ; in other words, is a “circle” of the metric .
For the square in Figure 2, , the sup or max norm , and . Using this with (3) is considerably simpler than finding and computing in (2). Moreover, it is conceptually satisfying that shape inversion be realized with the metric that defines the shape itself.
Further Examples with Known Metrics
This approach is readily extended to and higher-dimensional spaces. Cube inversion would use in analogy with the square. Other simple shapes of inversion include
- Octahedron with the Manhattan or Taxicab metric
- Rounded square with where k > 2
Constructing Metrics and Pseudo-Metrics from Shapes
For inversion with a general shape and the associated , my approach with (4) and (3) is needlessly complicated in comparison to (2). However, (4) provides a way to construct shape metrics for any application besides inversion. Note that these may not be metrics in the strict sense; see the ‘Caveats’ section for details.
Non-inversion Applications
Voronoi diagrams are colourings of the plane, based on a set of seed points. Each point on the plane is coloured according to its nearest seed. The “nearness” depends on the choice of the metric, so the style of a Voronoi diagram can be varied by using non-Euclidean distance functions. Figure 4(a) shows a Voronoi colouring with 32 seed points, using the pseudo-metric derived from the shape in Figure 3(a). The wavy nature of the shape metric is reflected in the shapes of the coloured partitions. For comparison, Figure 4(b) uses a metric mixed from Euclidean and Manhattan distances, namely , with the corresponding shape depicted in Figure 3(b).
Shape Metrics: A Unified Approach to Shape Inversions and Custom Distance
Functions
(a)
(b) Mixed Euclidean+Manhattan circle
(c)
Figure 3: Curved forms for constructing metrics and pseudo-metrics
Many graphics rendering techniques, such as ray tracing, rely on metrics due to their reverse nature. On a basic level, such algorithms comb over all points in the view, testing whether each point is in the desired set. For example, a sphere at the origin is generated by the test . Shape metrics provide an efficient solution to matching other shapes; the octahedron in Figure 1(b) is generated with the Manhattan metric.
Ray marching [2] is a variant of ray tracing that aims for faster rendering by skipping over empty areas. This requires an estimate of the Euclidean distance to the surface, which must not overshoot. In some cases, shape metrics can provide fast and safe estimates. For example, for a cube defined by , the distance from external points to its surface is at least . Other shape metrics may also be similarly applicable, possibly with a suitable scaling constant.
In 3D graphics, a realistic scene generally requires simulated lighting with surface reflections, which depend on the normal vectors of the surface. For a surface defined by a shape metric with , the surface normal at is simply given by the gradient . In some cases, this can be made simpler by using a suitable power or other modification of , provided it maintains the surface equation .
(a) Voronoi diagram using the pseudo-metric from Figure 3(a)
Figure 4: Applications of shape metrics
(b) Voronoi “giraffe” pattern
Euclidean + Manhattan metric
using (c) 1 Euro coin after a circle-to-square distortion
In Figure 1(b) I bring together a number of the techniques covered above: cube inversion with the max norm, octahedron shape matching and ray marching with the Manhattan metric, and lighting via surface
normals using the gradient of the metric. For the iteration with multiple inversion centres, I use optimizations adapted from Nakamura and Ahara [5].
Finally, for a bit of simple fun, smooth visual distortions can be realized with the shape metrics of the source and target shapes. For example, a disc-shaped picture can be transformed into a square with to produce results such as square coins (Figure 4(c)).
Alternative Definitions of Shape Metrics
Associating shapes with metrics is known in a number of disciplines. Perhaps the most famous example is Einstein’s general theory of relativity, an application of differential geometry where the metric tensor defines the shape of spacetime.
A closer example to the present definition is found in a study of geometric graphs by Bonato and Janssen [1]. They define where are the distinct surface normals of . This can be shown to be equivalent to (4) with a suitable normalization, at least for regular convex polygons.
Caveats
In general, shape metrics of arbitrary shapes will not fulfil the definition of a true metric, which includes the following two conditions:
- Symmetry the shape must be centrosymmetric, i.e. .
- Triangle inequality the shape must be convex. Although I have not proved this, it can be argued intuitively with counterexamples. In Figure 3(c), as the points and are on the unit “circle” of , while .
However, for artistic purposes, such conditions can be relaxed. Figure 3(a) represents a shape whose distance function breaks both of the above conditions, yet it is artistically useful for the making of Figure 4(a). In this case the violations result in visual discontinuities. Some of the colour partitions in Figure 4(a) are broken into separate parts, which can be seen as the “exclaves” without seed points. In contrast, Figure 4(b) exemplifies that even a rather simple, proper metric can be used to create interesting Voronoi diagrams.
Acknowledgements
My inversion art has been greatly inspired by Gregg Helt and Kento Nakamura, while Noira Martiskainen has provided other invaluable contributions to my works. Finally, I would like to thank the reviewers for their helpful suggestions.
References
- [1] Anthony Bonato and Jeannette Janssen. Infinite random geometric graphs from the hexagonal metric. Combinatorial Algorithms: 23rd International Workshop, IWOCA 2012, 7643, 07 2012.
- [2] Mikael H Christensen. Distance estimated 3d fractals (part i). http://blog.hvidtfeldts.net/index.php/2011/06/distance-estimated-3d-fractals-part-i/ (as of Sept. 3, 2019).
- [3] Krzysztof Gdawiec. Star-shaped set inversion fractals. Fractals, 22:1450009, 12 2014.
- [4] Gregg Helt. Extending mandelbox fractals with shape inversions. In Proceedings of Bridges 2018, pages 547–550, Phoenix, Arizona, 2018. Tessellations Publishing.
- [5] Kento Nakamura and Kazushi Ahara. A new algorithm for rendering kissing schottky groups. In Proceedings of Bridges 2016, pages 367–370, Phoenix, Arizona, 2016. Tessellations Publishing.