Search code examples
algorithmgeometrypolygoncomputational-geometrysymmetric

Check if a polygon is symmetric


Given a polygon (not necessary convex) in the Cartesian coordinate, i wonder if there are any way to check the symmetricalness of that polygon?

I can think of an O(N) solution: using rotating calipers to check if each pair of opposite edge is parallel and equal in size. However, i can't prove the correctness of that algorithm. Can you suggest any better solution?


Solution

    • You compute the center of gravity of your polygon.
    • You translate it to the origin so that your center of gravity has (0,0) as coordinate.
    • Then for each vertex of coordinate (i, j) you check that there is a vertex that has coordinates (-i, -j).

    This will prove that your polygon is symmetric indeed.

    Complexity : N, assuming you can access directly your vertices from their coordinates.