1
$\begingroup$

I am currently in the process of writing software and have encountered a mathematical problem. Perhaps there are some experts here who are familiar with this. It involves the classification of polygons with n points in 2D space, generalizing the classic convex and concave cases.

Each polygon is assigned a number of so-called "waterholes" and "airpockets." I imagine the polygon as a container that is filled with water from the deepest point (the first waterhole). During the filling process, the water may spill into lower areas, which would result in additional waterholes. The number of different points where the water touches the ceiling at possibly different locations, I call airpockets.

It's easy to see that a rectangle, regardless of its orientation, can always be assigned the tuple (1,1). It has exactly one waterhole and exactly one airpocket.

If the rectangle would stand straight, it would be of the same type (1,1). It doesn't matter if the water starts exactly at one point or at an edge.

Another example for illustration is the following zigzag shape: In two figures, I have drawn it once as type (2,2) and once as type (1,1).

The classification of a polygon depends on its orientation in the 2D space. Two congruent polygons might have different classifications.

My current pseudocode looks like this:

if polygon isConvex {
    return (1,1)
} else {
    ...
}

To check if a polygon is convex, I use the following algorithm: Form the cross product of two consecutive pairs of vectors that outline the polygon. If the x₃-component of the cross product is of the same sign for all these pairs, the polygon is convex.

Currently, my idea is to refine this algorithm further and create regions where the x₃ components are either positive, negative, or zero. Within these regions, I search for the point of the polygon with the highest or lowest y-component to conclude the existence of a waterhole or an airpocket.

When two consecutive vectors form a crossproduct with a positive x₃-value, the vectors are green. For negative values the vectors are red.

This seems complicated and fishy. Are there better ideas? Removing points of the polygon step by step and then checking each time for convexity/concavity?

tl;dr: I am looking for a mapping from $\mathbb{R}^{2n} \to \mathbb{R}^2$, which assigns to each polygon the number of its waterholes and airpockets. Bonus points if the index of the special points can also be extracted.

$\endgroup$
0

0

You must log in to answer this question.

Browse other questions tagged .