Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moment of area correctness issues #260

Closed
ljwolf opened this issue Aug 7, 2023 · 0 comments
Closed

Moment of area correctness issues #260

ljwolf opened this issue Aug 7, 2023 · 0 comments

Comments

@ljwolf
Copy link
Member

ljwolf commented Aug 7, 2023

Reported by email, our shape.second_areal_moment and nmi() functions need a few corrections:

  1. the input coordinate arrays need to be centered on the centroid (i.e. center of mass, not mean center)
  2. we need to use the sum of x and y moments, rather than the cross-xy moment.
  3. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant