Moment of area correctness issues
ljwolf opened this issue · 0 comments
ljwolf commented
Reported by email, our shape.second_areal_moment
and nmi()
functions need a few corrections:
- the input coordinate arrays need to be centered on the centroid (i.e. center of mass, not mean center)
- we need to use the sum of x and y moments, rather than the cross-xy moment.
- we need to use the parallel axis theorem to merge the inertial contributions from parts of multi-part polygons.
The hole + winding direction code should be correct as written using the correct moment of inertia calculation:
@njit
def _second_moa_ring_xplusy(points):
"""
implementation of the moment of area for a single ring
"""
moi = 0
for i in prange(len(points[:-1])):
x_tail, y_tail = points[i]
x_head, y_head = points[i + 1]
xtyh = x_tail * y_head
xhyt = x_head * y_tail
xtyt = x_tail * y_tail
xhyh = x_head * y_head
moi += (xtyh-xhyt)*(
x_head**2 + x_head*x_tail + x_tail**2
+ y_head**2 + y_head*y_tail + y_tail**2)
return moi/12
I should deal with this within a week or so, and this plus a few others (number fix, non-constructive minimum bounding circle index, correlogram) should make enough for a release!