It looks like you're new here. If you want to get involved, click one of these buttons!
I am attempting to calculate the principal moment of inertia of a polygon. I am looking for a way to slice a polygon into chunks such that I can more easily integrate over it. The biggest challenge is in decomplexifying less regular shapes.
I am unclear on how to partition a polygon into shapes that are properly weighted for their size. Put simply, I am looking for a way to more simply break a shape into smaller pieces. Using points is not the best way to identify the density of a shape. I am attaching this image to demonstrate my current method's problem:
In this image you can see two crosses, one (green and cyan) with hard-coded values representing the true center of mass, and another (blue and red cross) representing the calculated eigenvectors of the covariance matrix. Ideally the center of mass would occur in the green and cyan area. However, when calculating the eigenvalues and eigenvectors using points, the density of point locations causes the center of mass to shift to where the most dense number of points occur--around the blue and red cross.
Is there an object or method built-in that emulates a shape's edges as a dense line? To obtain the points, I am using something like for iter in layout.begin_shapes(cell, layer_indexes[idx]): polygon = iter.shape()
.
I am utilizing guidance to create this macro from this site and this one. I am certain there is a more simple way, but I am looking to build this for potentially more challenging shapes.
Comments
AFAIK the preferred way of computing weighted integrals over polygons (e.g. moments of inertia or Fourier coefficients) is using a Green's function - i.e. converting an area integral to an integral over the contour of the area.
As for a polygon the contour is piecewise linear, it is often possible to give analytical solutions or series approximations for the integrals over the linear parts. The contour integral then becomes the sum of the contributions for each edge.
But I don't have a numerical recipe at hand for this and I assume to implement that, a numerical library such a numpy is handy. The analytical solutions for Green's function for moments of inertia integrals of arbitrary order sure isn't trivial. I recall that we used these moments to classify error markers at times when classification wasn't called artificial intelligence, but I don't recall the derivations of the respective formulas. You may want to seek advise from someone who is friend with analytical integration.
Matthias
This has become a much more daunting challenge. Maybe you can help me with a solution to a simpler problem.
Is there a way to break the shapes into more simplified forms such that there is no loss to the area of the original shape? Is there an easy way to break larger shapes into a group of n- 3 or 4 sided polygons?
The harder shapes to decipher are the "circles". There isn't a clear way to get the radius without estimating, so I'm attempting to find a way to minimize the number of shapes I need to look at, and breaking the polyhedrons back into circle approximations is the biggest challenge. This will make calculating the integrals much easier.
I'm serious about the Greens function approach. It's a pain finding analytical solutions for area integrals even for simple quadrangles after decomposing them. Calculating an edge integral is far easier and accessible to analytical solutions.
Seek advice with someone that has the mathematical skills to help you with that.
Matthias
Hi double0darbo,
Not sure whether this suits you work workflow or can achieve the accuracy / performance you like, but should be the eaisiest ways to break complex shapes into simpler polygons
gds with Polygon can be resaved as dxf format with decomposed into solid selected will convert complex polygons into small polygons with maximum 4 sides.
or you can use region function
decompose_trapezoids
to achieve following results