Hausdorff distance between convex polygons

I am interested in calculating the Hausdorff distance between two polygons (in particular, quadrangles, which are almost rectangles) defined by their vertices. They may overlap.

Call $ d_H (A, B) = \ max (d (A, B), d (B, A)) $, where $ d $ is the Hausdorff semimetric $ d (A, B) = \ sup_ {a \ in A } \ inf_ {b \ in B} d (a, b) $.

Is it true that for a finite disjoint covering $ A $, $ {A_i} $, $ d (A, B) = \ max {d (A_i, B)} $? The consequence of this is that $ d (A, B) = d (A \ setminus B, B) $.

I found the Atallah 1 article (PDF) . I am interested in working in Python and would be open to any pre-programmed solutions.

+2
source share
1 answer

In the case of convex polygons, d(A, B) is the maximum distance from the vertices of A to any point in B Therefore, the Hausdorff distance is not too difficult to calculate if you can calculate the distance from an arbitrary point to a convex polygon.

To calculate the distance from a point to a convex polygon, you first need to check if the point is inside the polygon (if this distance is 0), and then if it does not find the minimum distance to any of the bounding segments of the line.

The answer to another request is no. As an example, let A and B both be the same 2x2 squares centered at the origin. Divide A into 4 1x1 squares. The Hausdorff distance from each A i to B is sqrt(2) , but the distance from A to B is 0.

UPDATE: The requirement for vertices is not immediately obvious, so I will draw a proof that is good in any finite number of dimensions. The result that I am trying to prove is that when calculating d(A, B) with both convex broken lines and B enough to find the distances from the vertices from A to B (The closest point in B may not be a vertex, but one of the farthest points in A must be a vertex.)

Since both are finite closed forms, they are compact. From compactness, there must exist a point p in A , as far as possible from B From compactness, there must exist a point q in B as close as possible to A

This distance is 0 only if A and B are the same polygon, and in this case it is clear that we reach this distance at the vertex A Therefore, without loss of generality, we can assume that there is a positive distance from p to q .

Draw a plane (in higher dimensions, some kind of hyperplane) tangent to q that is perpendicular to the line from p to q . Can any point in B cross this plane? Well, if it were, say r , then every point on the segment from q to r should be in B , because B is convex. But it is easy to show that there should be a point on this section of the line that is closer to p than q , which contradicts the definition of q . Therefore, B cannot cross this plane.

It is clear that p cannot be an internal point, because if that were the case, continue along the ray from q to p , and you would find points in A that are further from the plane on which B bounded behind, which contradicts the definition of p . If p is a vertex of A , then the result is trivially true. Therefore, the only interesting case is if p is on the boundary of A but is not a vertex.

If yes, then p is on the surface. If this surface were not parallel to the plane we built, it would be easy to move along this surface, moving away from the plane on which we confined ourselves to B , and find points farther from B than p . Therefore, this surface must be parallel to this plane. Since A finite, this surface must end somewhere at the vertices. These vertices are at the same distance from this plane as p and, therefore, are at least as far from B as p . Therefore, there is at least one vertex A , as far as possible, from B

That is why it was enough to find the maximum distances from the vertices of the polygons to another polygon.

(I leave building a pair of polygons with q not a vertex, as a reading exercise for the reader.)

+2
source

All Articles