Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Moment of area correctness issues #260

@ljwolf

Description

@ljwolf

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions