Between Shapes, Using the Hausdorff Distance
Marc van Kreveld, Tillmann Miltzow, Tim Ophelders, Willem Sonke, Jordi L. Vermeulen
BBetween Shapes, Using the Hausdorff Distance ∗ Marc van Kreveld Tillmann Miltzow Tim Ophelders Willem SonkeJordi L. Vermeulen
Abstract
Given two shapes A and B in the plane with Hausdorff distance , is there a shape S with Hausdorff distance / to and from A and B ? The answer is always yes, and dependingon convexity of A and/or B , S may be convex, connected, or disconnected. We show ageneralization of this result on Hausdorff distances and middle shapes, and various relatedproperties. We also show that a generalization of such middle shapes implies a morph witha bounded rate of change. Finally, we explore a generalization of the concept of a Hausdorffmiddle to more than two sets and show how to approximate or compute it. For two sets A and B in R , we define the directed Hausdorff distance as d (cid:126)H ( A, B ) = sup a ∈ A inf b ∈ B d ( a, b ) ,where d denotes the Euclidean distance. The undirected Hausdorff distance is defined as d H ( A, B ) = max( d (cid:126)H ( A, B ) , d (cid:126)H ( B, A )) .If A and B are closed sets then d H ( A, B ) = r is equivalent to saying that r is the smallest valuesuch that A ⊆ B ⊕ D r and B ⊆ A ⊕ D r , where ⊕ denotes the Minkowski sum, and D r is a diskof radius r centered at the origin. Recall that the Minkowski sum of sets A and B is the set { a + b | a ∈ A, b ∈ B } . In this paper we consider only closed sets, and therefore we can freely usethis containment property.The Hausdorff distance has been widely used in computer vision [15] and computer graph-ics [6, 12] for tasks such as template matching, and error computation between a model and itssimplification. At the same time, the Hausdorff distance is a classic mathematical concept. Our re-search motivation is to study this profound concept from a new perspective. Algorithms to computethe Hausdorff distance between two given sets are available for many types of sets, such as points,line segments, polylines, polygons, and simplices in k -dimensional Euclidean space [3, 4, 7]. How-ever, the question whether a polynomial time algorithm exists to compute the Hausdorff distancebetween general semialgebraic sets remains open [14].In this paper, we consider the natural problem of finding a set that lies “between” two or moreinput sets, in a Hausdorff sense. In Section 2 we investigate the Hausdorff middle of sets A and B ;this is a set that has minimum undirected Hausdorff distance to A and B . Differently put, itminimizes the maximum of four directed Hausdorff distances. We show that when the Hausdorffdistance between A and B is assumed to be , there is always a Hausdorff middle that has Hausdorffdistance / to A and B , and this is the best possible. We relate the convexity of A and/or B tothe convexity and connectedness of the Hausdorff middle, and study its combinatorial complexity.We actually treat the middle more generally, by defining a class of sets that smoothly inter-polate between A and B , giving a morph between them. Figure 1 shows two examples of such ∗ Research on the topic of this paper was initiated at the 4th Workshop on Applied Geometric Algorithms (AGA2018) in Langbroek, The Netherlands, supported by the Netherlands Organisation for Scientific Research (NWO)under project no. 639.023.208. The second author is supported by the NWO Veni grant EAGER. The first andfifth authors are supported by the NWO TOP grant no. 612.001.651. a r X i v : . [ c s . C G ] S e p igure 1: Hausdorff morphs between three shapes. A B A B A B
Figure 2: Three possible Hausdorff middles of A and B : two points, a line segment, and S / .morphs. We prove that this morph has a bounded rate of change. Our approach does not requireany correspondence between features of the input to be calculated. However, our approach isunusual in the sense that the intermediate shapes when morphing between e.g. two polygons arenot polygons themselves. Most morphing algorithms typically interpolate only the boundary, andkeep all intermediate shapes polygonal [5, 8, 9, 10, 11, 18].In Section 3 we extend to Hausdorff middles of more than two sets and generalize severalresults. We assume that the maximum Hausdorff distance over all pairs of input sets is andexamine the smallest Hausdorff distance for a middle set. That is, given sets M = { A , . . . , A k } ,we are interested in the value α ( M ) = min S max i =1 ,...,k d H ( A i , S ) . This value α ( M ) is no longer / , but depends on the input. For convex sets, we show that a value ≈ . can always be realizedand is sometimes necessary, whereas for non-convex sets it can be as bad as . For a given set ofpolygons with total complexity n , we show that α ( M ) and the Hausdorff middle can be computedin O ( n ) time, and, for any constant ε > , (1 + ε ) -approximated in O ( n log n log 1 /ε ) time. Wenote that other interpolation methods between two shapes do not have a natural generalization toa middle of three or more sets.Our proofs use three types of arguments. First, many of our arguments rely on simple manipu-lations of the formal definition of the Hausdorff distance. Those arguments immediately generalizeto other normed vector spaces, for instance, ( R d , (cid:107) · (cid:107) ∞ ) or the continuous functions endowed withthe uniform norm topology C ( R ) . We do not state those generalizations explicitly, as this is not ourfocus. The second type of argument is of a topological nature. Using continuity and connectivity,we infer related properties to the output, by constructing topological structures or conclude thatthey cannot exist. The third type of argument uses -dimensional Euclidean geometry directly. Weconstruct features, like vertices, edges and circular arcs and argue about their existence, and givedistance bounds. These arguments are often intricate and do not generalize. They are of particularvalue, as the -dimensional Euclidean plane is often the most interesting case in computationalgeometry. Consider two closed compact sets A and B in R ; we are interested in computing a Hausdorffmiddle : a set C that minimizes the maximum of the undirected Hausdorff distances to A and B .That is, C = argmin C (cid:48) max( d H ( A, C (cid:48) ) , d H ( B, C (cid:48) )) .Note that there may be many such sets that minimize the Hausdorff distance; see Figure 2 for a fewexamples. It might seem intuitive to restrict C to be the minimal set that achieves this distance,but this is ill-defined: the minimal set is not necessarily unique, and the common intersection ofall minimal sets is not a solution itself (see Figure 3). However, the maximal set is well-defined2 A / Figure 3: Two different minimal sets achieving minimal Hausdorff distance to A and B . S / A B Figure 4: Sets A and B for which S / is disconnected. The shaded areas around A and B represent A ⊕ D / and B ⊕ D / , respectively.and unique. Let d H ( A, B ) = 1 . Then S = ( A ⊕ D / ) ∩ ( B ⊕ D / ) is the maximal set with Hausdorff distance / to A and B (we prove this below in Lemma 2).We want to show that d H ( A, S ) ≤ / and d H ( B, S ) ≤ / . In fact, we can prove a more generalstatement.We define S α := ( A ⊕ D α ) ∩ ( B ⊕ D − α ) for α ∈ [0 , , and we use seg ( a, b ) to denote the linesegment connecting points a and b . Theorem 1.
Let A and B be two compact sets in the plane with d H ( A, B ) = 1 . Then d H ( A, S α ) = α and d H ( B, S α ) = 1 − α .Proof. We first show that d H ( A, S α ) ≤ α . The proof for d H ( B, S α ) ≤ − α is analogous andtherefore omitted. We will infer d H ( A, S α ) ≤ α from d (cid:126)H ( A, S α ) ≤ α and d (cid:126)H ( S α , A ) ≤ α ; thereafterwe will show equality.Consider any point a ∈ A ; by our assumption that d H ( A, B ) = 1 , there is a point b ∈ B with d ( a, b ) ≤ . Now consider a point s ∈ seg ( a, b ) with d ( a, s ) ≤ α and d ( b, s ) ≤ − α ; clearly thispoint must be in S α , as it is contained in both A ⊕ D α and B ⊕ D − α , and it has d ( a, s ) ≤ α .As this works for every a ∈ A , it holds that d (cid:126)H ( A, S α ) ≤ α . The fact that d (cid:126)H ( S α , A ) ≤ α followsstraightforwardly from S α being a subset of A ⊕ D α . Thus, d H ( A, S α ) ≤ α .To show equality, assume that the Hausdorff distance is realized by a point ˆ a ∈ A with closestpoint ˆ b ∈ B , at distance . Consider the point ˆ s ∈ seg (ˆ a, ˆ b ) with d (ˆ a, ˆ s ) = α and d (ˆ b, ˆ s ) = 1 − α .As observed, ˆ s ∈ S α . Since ˆ s is the closest point of S α to ˆ a , and ˆ b is the closest point of B to ˆ s ,equality follows. Lemma 2. S α is the maximal set that satisfies d H ( A, S α ) = α and d H ( B, S α ) = 1 − α .Proof. Consider any set T for which we have d (cid:126)H ( T, A ) ≤ α and d (cid:126)H ( T, B ) ≤ − α . As A ⊕ D α contains all points with distance at most α to A , we have that T ⊆ A ⊕ D α ; similarly, we havethat T ⊆ B ⊕ D − α . By the definition of S α , this implies that T ⊆ S α . As this holds for any T ,we conclude that S α is maximal. S α In this section, we study the convexity and connectedness of S α . Recall that a set A ⊆ R isconvex if for any two points a, b ∈ A , the segment seg ( a, b ) between them is completely contained3 / A Bb (cid:48) b πs s (cid:48) ρ ( b ) ρ ( b (cid:48) ) ρ / ( b ) ρ / ( b (cid:48) ) Figure 5: Illustration of the proof showing that S α is connected if A is convex (sketched for α = 3 / ). The shaded areas around A and B represent A ⊕ D / and B ⊕ D / , respectively,so that the doubly-shaded area is S / . A / B S / A B S / Figure 6: Although B is a translate of B , themiddle set between A and B is not a translateof the middle set between A and B .in A . Also, recall that a set A ⊂ R is connected if for any two points a, b ∈ A , there exists acontinuous curve c : [0 , → A such that c (0) = a and c (1) = b . This type of connectednessis known as path-connectedness, but we use the term connected for simplicity. We observe thefollowing properties:1. If A and B are convex, S α is convex;2. If A is convex and B is connected, S α is connected;3. For some connected sets A and B , S α is disconnected.Property 1 is straightforward: the Minkowski sum of A and B with a disk is convex, and the inter-section of convex objects is itself also convex. The example in Figure 4 demonstrates Property 3;in fact, any Hausdorff middle will be disconnected for those input sets.The next lemma establishes Property 2:
Lemma 3.
Let A and B be two connected regions of the plane with Hausdorff distance , and A convex. Then S α = ( A ⊕ D α ) ∩ ( B ⊕ D − α ) is connected for α ∈ [0 , .Proof. See Figure 5 for an illustration. Because A is convex, there is a continuous map ρ : B → A that maps each point of B to a closest point (within distance ) in A . For b ∈ B , let ρ α ( b ) = αρ ( b ) + (1 − α ) b . We have that ρ α : B → S α is also continuous.Now take any two points s and s (cid:48) in S α ; respectively, they have points b and b (cid:48) ∈ B withindistance − α . The segments between s and ρ α ( b ) and between s (cid:48) and ρ α ( b (cid:48) ) lie completely in S α .Take a continuous curve π from b to b (cid:48) inside B . The image of π under ρ α connects ρ α ( b ) to ρ α ( b (cid:48) ) within S α , so s and s (cid:48) are connected inside S α .We note that S α may contain holes. Furthermore, S α is not shape invariant when B is translatedwith respect to A . For example, let A be the union of the left and bottom sides of a unit square andlet B and B be the left and right sides of that same unit square. Then ( A ⊕ D / ) ∩ ( B ⊕ D / ) is not a translate of ( A ⊕ D / ) ∩ ( B ⊕ D / ) . See Figure 6; note that d H ( A, B ) = d H ( A, B ) . S α In this section, we describe the complexity of S α in terms of the number of vertices, line segments,and circular arcs on its boundary, for several types of polygonal input sets. Recall that ∂A denotesthe boundary of set A . 4 ⊕ b Figure 7: An arc b of ∂B ⊕ (blue) may intersect ∂A ⊕ (red) many times when α < − α . Lemma 4.
Let A be a convex polygon with n vertices and B a simple polygon with m vertices.Then S α consists of O ( n + m ) vertices, line segments and circular arcs, and this bound is tight inthe worst case.Proof. For brevity we let A ⊕ = A ⊕ D α and B ⊕ = B ⊕ D − α .There is a trivial worst-case lower bound of Ω( n + m ) by taking α = 0 or α = 1 . Note thatif the boundaries of A ⊕ and B ⊕ would consist of only line segments, the upper bound is easy toshow: A ⊕ is convex, and its boundary can therefore intersect each segment of ∂B ⊕ at most twice,making ∂S α consist of (parts of) segments from ∂A ⊕ and ∂B ⊕ and at most O ( m ) intersectionpoints. The problem is that ∂A ⊕ and ∂B ⊕ also contain circular arcs, in which case an arc of ∂B ⊕ may intersect ∂A ⊕ many times.To show an upper bound of O ( n + m ) , we distinguish two cases. In the first case, we assume α ≥ − α . Note that in this case, the circular arcs that are part of the boundary of A ⊕ have aradius larger or equal to those of B ⊕ . Additionally, ∂A ⊕ is smooth and an alternating sequence ofcircular arcs and segments, as A is convex. In this case, we do in fact have that any line segmentor circular arc b of ∂B ⊕ can intersect ∂A ⊕ at most twice. Consider two intersection points of b with ∂A ⊕ : as the curvature of ∂A ⊕ is at most that of b , there can never be another intersectionpoint between these two.For the second case, we assume α < − α . Again, take an arbitrary arc b of ∂B ⊕ that intersectssome arc a of ∂A ⊕ . We distinguish two cases: the center point of the disk whose boundary contains a is inside B ⊕ , or it is outside. If it is outside, b can only intersect ∂A ⊕ in two points. If it isinside, ∂A ⊕ may intersect b many times; see Figure 7. We charge these intersections to the arcsof ∂A ⊕ . We argue that each arc a of ∂A ⊕ is charged at most four times: Consider any α -disk D α and any (1 − α ) -disk D − α containing the center of D α , the latter will cover at least / of theperimeter of the former. Hence, the boundary of the union of any number of such (1 − α ) -disksintersects D α at most four times. The circular arcs of ∂A ⊕ cannot be charged more often becausethey are less than a full circle. Lemma 5.
Let A and B be two simply connected polygons of n and m vertices, respectively. Then S α consists of O ( nm ) vertices, line segments and circular arcs, and this bound is tight in the worstcase.Proof. The worst-case lower bound of Ω( nm ) follows by taking A and B to be two rotated “combs”;see Figure 4. For α = 1 / , S α consists of Ω( nm ) distinct components. The upper bound followsdirectly from the fact that A ⊕ D α and B ⊕ D α have complexities O ( n ) and O ( m ) , respectively.In fact, any Hausdorff middle has complexity Θ( nm ) for the example in Figure 4. S α ismaximal, and other middles must have at least some part of every component of S α . S α as a morph By increasing α from to , S α morphs from A = S into B = S . (Examples of such morphs arepresented in Figures 1 and 8.) The following lemma shows that this morph has a bounded rate ofchange. Lemma 6.
Let S α and S β be two intermediate shapes of A and B with α ≤ β . Then d H ( S α , S β ) = β − α . / AB S / S / Figure 8: Some examples of morphs S α between two shapes A and B .6 A B S / Figure 9: The left and middle figure show the offsets of A , respectively B with distance / . Theright figure shows the resulting S / in green. Any connected Hausdorff middle must cross thevertical middle line or stay on one side of it. In both cases, the Hausdorff distance doubles. Proof.
We have d H ( S α , S β ) ≥ β − α because, by the triangle inequality, d H ( A, B ) = 1 ≤ d H ( A, S α )+ d H ( S α , S β ) + d H ( S β , B ) ≤ α + d H ( S α , S β ) + 1 − β .It remains to show that d H ( S α , S β ) ≤ β − α . We show that S β ⊆ S α ⊕ D β − α ; the proof that S α ⊆ S β + D β − α is analogous. Let p be some point in S β . Then, by definition of S β , there existsome points a ∈ A and b ∈ B such that d ( a, p ) ≤ β and d ( b, p ) ≤ − β . Let ¯ p be the pointobtained by moving p in the direction of a by β − α . By the triangle inequality, we then have that d ( a, ¯ p ) ≤ β − ( β − α ) = α and d ( b, ¯ p ) ≤ (1 − β ) + ( β − α ) = 1 − α . This implies that ¯ p ∈ S α .As p was an arbitrary point in S β , and d ( p, ¯ p ) ≤ β − α , we have that S β ⊆ S α ⊕ D β − α . So d H ( S α , S β ) ≤ β − α .The lemma implies that, even though the number of connected components of S α can changewhen α changes, new components arise by splitting and never ‘out of nothing’, and the number ofcomponents can only decrease through merging and not by disappearance.The morph from A to B has a consistent submorph property, formalized below. Observation 7.
If a morph from A = S to B = S contains a shape C , then the morph from A to C concatenated with the morph from C to B is the same as the morph from A to B : theycontain the same collection of shapes in between and in the same order. As a corollary of this observation, { α ∈ [0 , | S α is convex } is a connected interval. For some applications, it might be necessary to insist that S α is always connected. However, inthe worst case, the cost of connecting all components of S α can be that its Hausdorff distance to A and B becomes . See Figure 9 for an example where this is the case. In fact, any connectedHausdorff middle has distance for this example. A natural question is whether the results from the previous section extend to more than two inputshapes. There are several ways to formalise the notion of a Hausdorff middle between multipleshapes. Analogous to the case of two sets, we are interested in a middle shape that minimizes themaximum Hausdorff distance to each input set. Let M = { A , . . . , A m } be a collection of m inputshapes with largest pairwise Hausdorff distance . We define T α as (cid:84) i ( A i ⊕ D α ) ; the (maximum)middle set is then given by the smallest value α for which T α ⊕ D α contains all input sets. Wedenote this smallest α by α ( M ) := min { α | max i d H ( A i , T α ) ≤ α } . If α is clear from the context,we use the notation A ⊕ to mean A ⊕ D α .In this section, we first study the largest possible α ( M ) for general and convex input. We thenstudy some general properties of T α with respect to connectivity and convexity. After this, weconsider whether there is some subset of M that requires the same value of α , and obtain a Helly-type property for convex input. Lastly, we will give various algorithms to compute or approximate α ( M ) efficiently. 7 T α T ⊕ α Figure 10: The pairwise Hausdorff distance in this construction is , and for any α < , T ⊕ α doesnot contain point p . r = α θ θ λ A A A T r Figure 11: Three segments A , A , and A . Of these, A is the diameter of a circle with radius r ;the other two ( A and A ) are tangent to the circle and are copies of one another reflected through A , such that all pairwise Hausdorff distances are at most (length of dashed segments). The topleft vertex of A is furthest (at distance r ) from the middle set T r (green), so α ( { A , A , A } ) isthe radius r of the circle. α ( M ) In this section, we are interested in the largest possible value of α ( M ) . We first discuss the generalcase and then study the case where all sets A ∈ M are convex. In both cases, we provide an exactanswer. This section relies on some tedious calculations, which turn out to be easier if we do notnormalize pairwise distances of our objects to 1.As it turns out, for some inputs it may be the case that α ( M ) = 1 ; see Figure 10. Here, therecan be no shape with Hausdorff distance < to all the input shapes, meaning any of the threeinput shapes can be chosen as “the middle”. Hence, for two sets, we always have α ( M ) = 1 / , butfor more sets, it depends on the input, and α ( M ) will be in [1 / , . The example in Figure 10requires non-convex sets, raising the question of what the range of α ( M ) can be when all A i areconvex.If we have three convex sets that are points, and they form the corners of an equilateral unit-side triangle, then we can easily see that α ( M ) = 1 / √ ≈ . and the middle shape is exactlythe point in the middle of the triangle.An example with three line segments shown in Figure 11 surprisingly achieves (for λ ≈ . , θ ≈ . ◦ ) a larger value α ∗ ≈ . r , which we call the magic value . Lemma 9 shows thatno three convex sets achieve α ( M ) > α ∗ . Thus the magic value is the best possible upper boundfor three convex sets.We define the magic value as α ∗ = 1 /z ≈ . , where z := min { λ + 1 − cos(2 θ ) | λ ≥ , θ ∈ (90 ◦ , ◦ ) , and λ + 1 − cos(2 θ ) = (cid:107) ( − λ cot(2 θ ) − sin(2 θ ) + sin( θ ) , λ − cos(2 θ ) + cos( θ )) (cid:107)} ≈ . (at λ ≈ . , θ ≈ . ◦ , verified using Wolfram Cloud).8 zα θθ b ( θ ) = ( − α sin(2 θ ) , α − α cos(2 θ )) t = (0 , α )( − α sin( θ ) , α − α cos( θ )) = a p λ ( θ ) = ( − λ cot(2 θ ) − α sin(2 θ ) , λ + α − α cos(2 θ )) λC H ( θ ) b ( − θ ) = (0 , H ( − θ ) H t Figure 12: Derivation of the expression for z . Lemma 8.
Let M = { A , . . . , A m } be a collection of convex regions in the plane, and α := α ( M ) .There is some A i ∈ M with d (cid:126)H ( A i , T α ) = α .Proof. By construction, we have d (cid:126)H ( T β , A i ) ≤ β for all i and all β . (Recall that this is equivalentto T β ⊆ A i ⊕ D β .) Moreover, if T β is nonempty, then for any i , the map γ (cid:55)→ d (cid:126)H ( T γ , A i ) iscontinuous on the domain [ β, ∞ ) , as T γ changes continuously. We show that for some i , we have d (cid:126)H ( A i , T α ) = α . If instead d (cid:126)H ( A i , T α ) < α for all i , then unless T β is empty for all β < α , wecan decrease α , contradicting minimality of α . If instead α is the minimal value for which T α is nonempty, then T α has no interior (when viewed as a subset of the plane). Because T α is theintersection of convex sets, it is convex. If it has no interior, it is either a segment or a point, andby convexity it must lie on the boundary of A ⊕ i for some i , contradicting that d (cid:126)H ( A i , T α ) < α . Lemma 9.
Let M = { A , A , A } be convex regions in the plane. Let α := α ( M ) and d =max i,j d H ( A i , A j ) , then d ≥ α/α ∗ (equivalently d ≥ zα ).Proof. By Lemma 8, we have d (cid:126)H ( A i , T α ) = α for some i . If x is a point, we will write (cid:126)d ( x, · ) todenote d (cid:126)H ( { x } , · ) . Without loss of generality assume that d (cid:126)H ( A , T α ) = α and (cid:126)d ( a, T α ) = d ( a, t ) = α with a ∈ A and t ∈ T α . Let T = A ⊕ ∩ A ⊕ ⊇ T α . There is no point t (cid:48) ∈ T with d ( t (cid:48) , a ) < α , sincethen (cid:126)d ( t (cid:48) , A ) < α , in which case t (cid:48) ∈ A ⊕ and therefore t (cid:48) ∈ T α , contradicting that d (cid:126)H ( a, T α ) = α .So t is a point in T closest to a and hence (cid:126)d ( a, T ) ≥ α .Assume that α > (otherwise we are done) and let H t be the half-plane (not containing a )bounded by the line through t that is perpendicular to seg ( t, a ) , see also Figure 12. The set T is convex, as it is the intersection of convex sets. Therefore, if T contains a point p , then T alsocontains seg ( t, p ) . Since t is a point of T closest to a , no such segment intersects the open disk ofradius α centered at a , and therefore T ⊆ H t .Let C be the circle of radius α centered at t . For the remainder of the proof, let i ∈ { , } . Let b i be a point of A i closest to t . Then b i lies on or inside C . If b i (cid:54) = t , we can define the half-plane H i (not containing t ) bounded by the line through b i that is perpendicular to seg ( t, b i ) . For b i (cid:54) = t ,we have by convexity of A i and b i being closest to t that A i ⊆ H i , so (cid:126)d ( a, A i ) ≥ (cid:126)d ( a, H i ) . Withoutloss of generality, assume that (cid:126)d ( a, H i ) < α/α ∗ (otherwise d ≥ d (cid:126)H ( A , A i ) ≥ (cid:126)d ( a, A i ) ≥ α/α ∗ ).If d ( a, b i ) ≥ α , then b i lies diametrically opposite a on C , but then (cid:126)d ( a, H i ) ≥ α > α/α ∗ ,which is a contradiction, so d ( a, b i ) < α . Let t i ∈ A ⊕ i be the midpoint of b i and a , then d ( a, t i ) <α ≤ d ( a, t ) . If d ( b , t ) < α , then T contains a point interior to seg ( t, t ) , contradicting that (cid:126)d ( a, T ) ≥ α . So b and (symmetrically) b lie on C .Let θ i be the clockwise angle ∠ atb i ∈ ( − ◦ , ◦ ) . Define b ( θ ) to be the point on C for which θ is the clockwise angle ∠ atb ( θ ) , so that b i = b ( θ i ) . Similarly, let H ( θ ) be the half-plane (notcontaining C ) bounded by the line tangent to C at b ( θ ) , so that H i = H ( θ i ) . Assume withoutloss of generality that | θ | ≥ | θ | (otherwise relabel A and A ). If θ and θ are both positive orboth negative, then t is contained in A ⊕ D α and therefore t ∈ T α , which is a contradiction. So9ssume without loss of generality that θ ≤ ≤ θ (otherwise mirror all points). If θ − θ < ◦ ,then T contains the segment between t and the midpoint of b and b . This segment does not liein H t , which contradicts that T ⊆ H t . Moreover, if θ − θ = 180 ◦ , then b and b are antipodalon C , so d H ( A , A ) ≥ d H ( H ( θ ) , H ( θ )) ≥ α > α/α ∗ . So θ − θ > ◦ .In fact, it will turn out that in the worst case, θ = − θ . Suppose that p ∈ A ⊆ H ( θ ) is thepoint of A closest to a . We have d ≥ d ( a, p ) and d ≥ (cid:126)d ( p, A ) ≥ (cid:126)d ( p, H ( θ )) . Moreover, since − θ ≤ θ < θ − ◦ , the value of (cid:126)d ( p, H ( θ )) decreases as θ ∈ [ − θ , θ ] decreases. In particular, we have (cid:126)d ( p, H ( θ )) ≥ (cid:126)d ( p, H ( − θ )) . Since | θ | ≥ | θ | , we have θ ∈ (90 ◦ , ◦ ) . Let λ p = (cid:126)d ( p, H ( − θ )) − (cid:126)d ( b ( θ ) , H ( − θ )) . If λ p < , then d ( a, b ( θ )) < d ( a, p ) , and p would not be a point of A closestto a . Combining the above lower bounds, we obtain d ≥ min { max { d ( a, p ) , (cid:126)d ( p, H ( − θ )) } | p ∈ H ( θ ) , λ p ≥ } . The above inequality is minimized for some p on the boundary of H ( θ ) . Weparameterize such points p with parameters λ and θ : let p λ ( θ ) be the unique point on theboundary of H ( θ ) with (cid:126)d ( p λ ( θ ) , H ( − θ )) = (cid:126)d ( b ( θ ) , H ( − θ )) + λ . The above inequality becomes d ≥ min λ ≥ max { d ( a, p λ ( θ )) , (cid:126)d ( b ( θ ) , H ( − θ )) + λ } .We need to minimize this quantity over all values of λ ≥ and θ ∈ (90 ◦ , ◦ ) . We willshow that it is minimized when its terms d ( a, p λ ( θ )) and (cid:126)d ( b ( θ ) , H ( − θ )) + λ are equal. Thepoint p λ ( θ ) , and hence the two terms, vary continuously in λ and θ . For fixed θ , both termsare convex as a function of λ . Therefore, for any fixed θ , the function is minimized either when λ = 0 , or the two terms are equal. As θ approaches ◦ , the first term approaches at least α (for any λ ), and as θ approaches ◦ , the second term approaches at least α . Since the optimalvalue is less than α , there exists an optimal value of θ . Assume for a contradiction that theterms are not equal in an optimal solution. Fix λ = 0 , and consider the two terms as a functionof θ . For θ ≈ ◦ and λ = 0 , we have d ( a, p λ ( θ )) ≈ α < α ≈ (cid:126)d ( b ( θ ) , H ( − θ )) + λ . Converselyfor θ ≈ ◦ and λ = 0 , we have d ( a, p λ ( θ )) ≈ α > ≈ (cid:126)d ( b ( θ ) , H ( − θ )) + λ . Hence, by theintermediate value theorem, the inequality as a function of θ (with fixed λ = 0 ) is minimizedwhen the terms are equal. We handled the case with λ > above, so our inequality becomes d ≥ min { (cid:126)d ( b ( θ ) , H ( − θ )) + λ | λ ≥ , θ ∈ (90 ◦ , ◦ ) , and d ( a, p λ ( θ )) = (cid:126)d ( b ( θ ) , H ( − θ )) + λ } .Following the derivation in Figure 12, this corresponds to d ≥ zα = α/α ∗ . T α In this subsection, we use α := α ( M ) for simplicity. Similar to Section 2.1, we examine theproperties of T α for different types of input. We arrive at straightforward generalizations of theresults obtained for two sets:1. If all A i are convex, then T α is convex.2. If one of the A i is connected and the rest are convex, then T α is connected.3. For some input where each A i is connected, and at least two are not convex, T α is discon-nected.Property 1 follows from the same argument as before: T α is the intersection of convex sets,and therefore itself convex. Property 3 can be shown by extending the construction from Figure 4with some other sets: if the intersection of two of the sets is not connected, adding more sets willnot make T α connected as long as the pairwise Hausdorff distance does not increase. We establishProperty 2 with the following lemma: Lemma 10.
Let M = { A , . . . , A m } be a set of connected regions of the plane, with A i convex for i < m . Then T α is connected.Proof. Consider the set T (cid:48) α = (cid:84) m − i =1 A ⊕ i . This set is convex, as it is the intersection of convexsets. Also note that by definition of T α , A m has directed Hausdorff distance at most α to T (cid:48) α . Let A = T (cid:48) α and B = A m , normalised such that d (cid:126)H ( B, A ) = 1 . We now apply Lemma 3 to A and B ,using zero as the value for α . We obtain the result that T α = T (cid:48) α ⊕ D ∩ A m ⊕ D α is connected.Note that the Hausdorff distance from A to B may be bigger than one, but this does not matterfor the proof of Lemma 3. 10 h = 1 r = 1 + ε (a) α = ε T α α = ε (b) α = ε/ T α (c) Figure 13: When the input sets are not convex, all sets may be necessary to realise the value of α . The black circle is part of the purple, red and orange sets; each pair of sets has an overlappingprotrusion, spaced equally around the circle. (a) shows the radius of the circle and the Hausdorffdistance. (b) shows that when all sets are present, the required value of α is (1 + ε ) / . (c) showsthat with the orange set removed, the required value of α is reduced to (1 + ε/ / : the dilation ofthe protruded part of T α fully contains the part of the disk that would otherwise not be covered,indicated by the dashed and dotted arcs. An interesting question is whether there are any sets in the input that could be removed whilemaintaining the same optimal value of α . To make this precise, we need some definitions. Wesay a collection M of m sets is d -sufficient , if there is a collection M d ⊂ M of d sets such that α ( M ) = α ( M d ) . Lemma 11.
For every m , there is a collection M of m connected sets in the plane that is not ( m − -sufficient. Figure 13 depicts a collection of four sets which are not -sufficient. The example has one setthat is a disk of radius ε (shown in green on the left), and m − sets that are circles on theboundary of this disk with m − protrusions of some small length ε . These protrusions are evenlyspaced along the boundary of the disk, and in each location there is a distinct set out of the m − sets missing (each subset of size m − is represented by some protrusion). This way, for the casewhere all sets are present (Figure 13(b)), the protrusions don’t have any influence on T α , meaningthat α ≥ (1 + ε ) / is required to let T ⊕ α contain the entire disk. However, if we remove one set(other than the green disk), there will be one protrusion where all sets are now present, meaningit will change the shape of T α (Figure 13(c)). Because of this, the centre of the disk will alreadybe covered with a smaller value of α , namely (1 + ε/ / . Note that if we remove the green disk, itis sufficient to use a value of α = ε/ . Further note that with a minor adaptation, all sets becomepolygonal and simply-connected.We have shown that in general, we cannot remove any sets from the input while maintainingthe same value of α . However, when all input sets are convex, we can show that there is always asubset of size at most three that has the same optimal value of α . Lemma 12.
Let M = { A , . . . , A m } be a collection of convex sets. Then there exists a subcollection M (cid:48) ⊆ M of size at most three such that α ( M ) = α ( M (cid:48) ) .Proof. Consider growing some value β from / to . At some point, T ⊕ β contains all sets in M .There are two ways in which this can happen: (1) T β is non-empty for the first time, and imme-diately the condition holds, or (2) T β grows, and its dilation now covers the last point of all setsin M . As T β is convex no new components can appear except for the first, and thus we have onlythose two cases.In Case 1, T β is either a segment or a point. If it is a segment, it is generated by two paralleledges of some A i , A j ∈ M such that we have α ( { A i , A j } ) = α ( M ) . If it is a point, it is thecommon intersection of the dilation of some number of sets from M ; we argue that you can always11ick three sets for which β is optimal. Let a be the single point in T β ; consider the vectors V perpendicular to the boundaries of the dilated input sets intersecting in this point. The vectors V must positively span the plane : otherwise, all vectors would lie in the same half-plane, and a would not be the first point to appear in T β . As we are in the plane, there must be subset U ⊂ V of three vectors that positively span the plane by themselves. The three corresponding sets A i , A j , A k ∈ M satisfy α ( { A i , A j , A k } ) = α ( M ) .In Case 2, as our input sets are convex, T β itself is also convex. Let a ∈ A i be the last pointof M to be covered by T ⊕ β . As T ⊕ β is convex, a must be on its boundary, and therefore either onan edge or a circular arc of T ⊕ β . Each edge can be traced back directly to an edge of some A j , inwhich case A i and A j have Hausdorff distance β , and α ( { A i , A j } ) = α ( M ) for any choice of k .Each circular arc is generated by a vertex of T β , which in turn is generated by the intersection ofthe boundaries of some A ⊕ j and A ⊕ k , in which case we also have that α ( { A i , A j , A k } ) = α ( M ) .Combining the previous lemma with Lemma 9, we obtain the following result. Theorem 13.
Let M = { A , . . . , A m } be a collection of convex regions in the plane, and let T α = (cid:84) i A ⊕ i . Then α ( M ) is at most the magic value α ∗ ≈ . . For any given collection of shapes M = { A , . . . , A m } , we want to compute α ( M ) . We presenttwo algorithms, a simple approximation algorithm and a more complex exact algorithm. Theyboth use the same decision algorithm as a subroutine. To be precise: given a collection of sets M and some α , the decision algorithm decides if α ≤ α ( M ) . We first present an algorithm forthe decision problem. Then we sketch how they are used in the approximation algorithm and theexact algorithm. We denote all vertices and edges of the A i as features of M . Decision algorithm
Assuming the input has total complexity n , we can test a given value of α as follows. Compute the intersection T α of the dilations A ⊕ , . . . , A ⊕ m in O ( n log n ) time, usingthe construction of an arrangement of straight and circular arcs [19]. The set T α will always haveat most quadratic complexity, but it can be disconnected. Next we compute T ⊕ α . We take everyconnected component T of T α separately, compute T ⊕ , and then compute their union. Since theconnected components of T α are disjoint and can be partitioned into O ( n ) convex pieces, theMinkowski sums of these pieces with D α form a set of pseudo-disks with summed complexity O ( n ) , see [20]. It is known that such a union has O ( n ) complexity and can be computed in O ( n log n ) time [1, 20]. Thus, we can compute T α in O ( n log n ) time.Note that T α ⊆ A ⊕ i , by definition. It remains to test A i ⊆ T ⊕ α , for each A i . We test allthose containments by a standard plane sweep [13] in O ( n log n ) time. As soon as we find anyproper intersection between an arc of ∂ ( T ⊕ α ) and some edge of some ∂A i , we can stop the sweepand conclude that α needs to be larger. If there were no proper intersections of this type, therewere only O ( n ) events (and not O ( n ) ), including the ones between edges of different ∂A i . Whenthere are no proper intersections, each shape A i lies fully inside or outside T ⊕ α . We can test thisin O ( n log n ) time (replace each A i by a single point and then test by a plane sweep or planarpoint location [13]), and conclude that α must be larger or smaller than the one tested. Thus thisdecision algorithm takes O ( n log n ) total time. Approximation algorithm
The decision algorithm leads to a simple approximation algorithmto find a value of α that is at most a factor ε from the optimum. We can perform (cid:100) log 1 /ε (cid:101) steps of binary search in the range [1 / , , testing if T ⊕ α contains all A i using the above decisionalgorithm. This takes O ( n log n log 1 /ε ) time in total. Exact computation
We can compute an exact value of α ( M ) in polynomial time. To this end,we imagine a continuous process where we grow α from / , and keep track of T ⊕ α . The first time(smallest α ) T ⊕ α covers all A i , we have found the Hausdorff distance α ( M ) corresponding to the We say v i ∈ R span the plane positively , if for every point p ∈ R there are some numbers a i ∈ R + such that (cid:80) a i v i = p . α α α ααα α Figure 14: Left, two sets shown by red and blue line segments, and the construction of T α fromlines parallel to edges of M and circles centered at vertices of M . Right, construction of T ⊕ α fromlines at distance α from edges of M , circles of radius α centered at vertices of M , and circles ofradius α centered at certain vertices of T α .Hausdorff middle, and we can construct T α explicitly as the Hausdorff middle. Such an approach issometimes called wavefront propagation or continuous Dijkstra ; it has been used before to computeVoronoi diagrams [13, 17], straight skeletons [2] and shortest paths on terrains [22]. This approachis combinatorial if there are finitely many events and we can determine each on time, before itoccurs. Instead of explicitly maintaining T ⊕ α when α grows, we will determine a polynomial-sizeset of critical α values that contains the sought one, and find it by binary search, using the decisionalgorithm described.The value α ( M ) that we aim to compute occurs when T ⊕ α has grown just enough to cover all A i . This can happen in three ways, roughly corresponding to a vertex of A i becoming covered,an edge of A i becoming covered at some point “in the middle”, or a hole of T ⊕ α collapsing anddisappearing interior to A i . We call the vertices, edges, and arcs of M and T ⊕ α the features (oftheir boundaries). The three ways of covering all A i , expressed in the features of M and T ⊕ α , arenow: (1) a feature of T ⊕ α coincides with a vertex of some A i , (2) a vertex of T ⊕ α lies on a feature ofsome A i , or (3) features of T ⊕ α collapse and cause a hole of T ⊕ α to disappear. In the last case, whenthat hole was inside some A i , this can be the event where A i is covered fully for the first time. Inall cases, one, two, or three features of T ⊕ α and zero or one feature of some A i are involved, and atmost three features in total. When three edge or circular arc features pass through a single pointfor some value of α , we say that these features are concurrent . Similarly, when an edge or circulararc passes through a vertex for some α , we say they are concurrent.It can be that more than three features of T ⊕ α pass through the point where, e.g., a hole in T ⊕ α disappears, but then we can still determine this critical value by examining just three features of T ⊕ α , and computing the α value when the curves of these three features are concurrent.Let us analyze which features make up the boundary of T ⊕ α , see Figure 14. There are four types:(1) straight edges, which are at distance α from an edge of M , and parallel to it, (2) circulararcs of radius α , which are parts of circles centered at vertices of M , (3) circular arcs of radius α , centered at a vertex of T α , and (4) vertices where features of types (1)–(3) meet. Every one ofthe features of the boundary of T ⊕ α is determined by one or two features of M . In particular, eacharc of type (3) is centered on an intersection point which is a vertex of T α , of which there can be Θ( n ) in the worst case (Figure 4). Depending on the type of intersection point, its location maychange linearly in α , or according to a low-degree algebraic curve (when the intersection has equaldistance α to an edge and a vertex of M ).Since any critical value can be determined as a concurrency of two (vertex and edge or arc) orthree features (three edges or arcs) from M and T ⊕ α , and features of T ⊕ α in turn are determined byup to two features of M , every critical value depends on at most six features of the input, M . Ifwe choose any tuple with up to six features of M , and compute the α values that may be critical,13e obtain a set of O ( n ) values that contain all critical α values, among which α ( M ) . We cancompute this set in O ( n ) time, as it requires O (1) time for each tuple of up to six features of M . Theorem 14.
Let M be a collection of m polygonal shapes in the plane with total complex-ity n , such that the Hausdorff distance between any pair is at most , and let ε > be a con-stant. The Hausdorff middle can be computed exactly in O ( n ) time, and approximated within ε in O ( n log n log 1 /ε ) time. Parametric search could result in a faster exact algorithm, but for this one would need toexpress whether input features are close to a given S α in terms of low degree polynomials. This isnontrivial given that S α as function of α varies in a complex manner. We have defined and studied the Hausdorff middle of two planar sets, leading to a new morphbetween these sets. We also considered the Hausdorff middle for more than two sets. Whilewe assumed that the input sets are simply-connected, our definition of middle and the morphimmediately generalize to more general sets, like sets with multiple components and holes. In thissense our definition of middle is very general. Other interpolation methods between shapes do notgeneralize to more than two input sets and cannot easily handle sets with multiple components.There are many interesting open questions. For example, when both input sets are one-dimensional curves, is there a natural way to define a Hausdorff middle curve that is also -dimensional?Besides the maximal middle set, there are other options for a Hausdorff middle. For example,we can choose S α clipped to the convex hull of A ∪ B , which is also a valid Hausdorff middle. InFigure 9, the green shape would be reduced to the part inside the square, which may be morenatural. This Hausdorff middle can also be used in a morph.Another interesting question could be if, for two shapes A and B , we can find a translation orrigid motion of A such that some measure on the Hausdorff middle (e.g. area, perimeter, diameter)is minimised.For two or more shapes in the plane, we could also define a middle based on area-of-symmetric-difference. Here we may want to average the areas for the middle shape, and possibly choose themiddle that minimizes perimeter. This problem is related to minimum-length area bisection [21].Similarly, for a set of curves, we could define a middle curve based on the Fréchet distance.This appears related to the Fréchet distance of a set of curves rather than just a pair [16]. References [1] P.K. Agarwal, J. Pach, and M. Sharir. State of the union (of geometric objects). Technicalreport, American Mathematical Society, 2008.[2] O. Aichholzer, F. Aurenhammer, D. Alberts, and B. Gärtner. A novel type of skeleton forpolygons.
Journal of Universal Computer Science , 1(12):752–761, 1995.[3] H. Alt, B. Behrends, and J. Blömer. Approximate matching of polygonal shapes.
Annals ofMathematics and Artificial Intelligence , 13(3):251–265, Sep 1995.[4] H. Alt, P. Braß, M. Godau, C. Knauer, and C. Wenk. Computing the Hausdorff distanceof geometric patterns and shapes. In Boris Aronov, Saugata Basu, János Pach, and MichaSharir, editors,
Discrete and Computational Geometry - The Goodman-Pollack Festschrift ,pages 65–76. Springer, 2003.[5] H. Alt and L.J. Guibas. Discrete geometric shapes: Matching, interpolation, and approxima-tion. In
Handbook of Computational Geometry , pages 121–153. Elsevier, 2000.[6] Nicolas Aspert, Diego Santa-Cruz, and Touradj Ebrahimi. Mesh: Measuring errors betweensurfaces using the Hausdorff distance. In
Proc. IEEE International Conference on Multimediaand Expo , volume 1, pages 705–708, 2002. 147] M.J. Atallah. A linear time algorithm for the Hausdorff distance between convex polygons.
Information Processing Letters , 17(4):207 – 209, 1983.[8] G. Barequet, M.T. Goodrich, A. Levi-Steiner, and D. Steiner. Contour interpolation bystraight skeletons.
Graphical Models , 66(4):245–260, 2004.[9] G. Barequet and M. Sharir. Piecewise-linear interpolation between polygonal slices.
ComputerVision and Image Understanding , 63(2):251–272, 1996.[10] G. Barequet and A. Vaxman. Nonlinear interpolation between slices.
International Journalof Shape Modeling , 14(01):39–60, 2008.[11] J.-D. Boissonnat. Shape reconstruction from planar cross sections.
Computer Vision, Graph-ics, and Image Processing , 44(1):1–29, 1988.[12] Paolo Cignoni, Claudio Rocchini, and Roberto Scopigno. Metro: measuring error on simplifiedsurfaces. In
Computer Graphics Forum , volume 17, pages 167–174, 1998.[13] M. de Berg, O. Cheong, M. van Kreveld, and M. Overmars.
Computational Geometry: Algo-rithms and Applications . Springer, 3rd edition, 2008.[14] M.G. Dobbins, L. Kleist, T. Miltzow, and P. Rzążewski. ∀∃ R -completeness and area-universality. In International Workshop on Graph-Theoretic Concepts in Computer Science ,pages 164–175. Springer, 2018.[15] M.-P. Dubuisson and Anil K. Jain. A modified hausdorff distance for object matching. In
Proceedings of 12th IEEE International Conference on Pattern Recognition , volume 1, pages566–568, 1994.[16] A. Dumitrescu and G. Rote. On the Fréchet distance of a set of curves. In
CCCG , pages162–165, 2004.[17] S. Fortune. A sweepline algorithm for Voronoi diagrams.
Algorithmica , 2(1-4):153, 1987.[18] C. Gotsman and V. Surazhsky. Guaranteed intersection-free polygon morphing.
Computers& Graphics , 25(1):67–75, 2001.[19] D. Halperin and M. Sharir. Arrangements. In C.D. Tóth, J. O’Rourke, and J.E. Good-man, editors,
Handbook of Discrete and Computational Geometry , chapter 28, pages 723–762.Chapman and Hall/CRC, 3rd edition, 2018.[20] K. Kedem, R. Livne, J. Pach, and M. Sharir. On the union of Jordan regions and collision-free translational motion amidst polygonal obstacles.
Discrete & Computational Geometry ,1(1):59–71, 1986.[21] E. Koutsoupias, C. H. Papadimitriou, and M. Sideri. On the optimal bisection of a polygon.
ORSA Journal on Computing , 4(4):435–438, 1992.[22] J.S.B. Mitchell, D.M. Mount, and C.H. Papadimitriou. The discrete geodesic problem.