I want to calculate the principle axis of the second monument of area of polygons and was wondering if there were any existing implementations of it.
This is related to the centroid, which is the first moment of area. It can be calculated it from the second moment of area, arctan(Ixy/(Ixx-Iyy))/2. So if there was a cacluation package existing that calculated the second moments of area that would work too. See https://en.wikipedia.org/wiki/Second_moment_of_area#Any_polygon
Why use the principal axis of the second moment of area? It provides a more stable interpretation of the principal axis in comparison the orientation of the convex hull or minimum bounding rectangle or the polygon main angle, particularly with concave polygons and polygons with holes. If you would suggest another measure that would be good for identifying the major axis of the polygon, which behaves well with highly concave polygons, I would be open to suggestions.
sympy comes to mind
sympy/sympy/geometry/polygon.py at 16fa855354eb7bcabd3fe10993841e03b1382692 · sympy/sympy
under the Polygon class methods