Compaction and separation algorithms for non-convex polygons and their applications