calculating polygon's rectangle