You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(center-of-mass): calculate polygon centroids ring by ring - #3174
centerOfMass joined polygon rings, adding artificial edges and returning the wrong centroid for polygons with holes.
We sum each ring separately and subtract hole areas and moments regardless of winding.
We tested the reported example, both polygon input forms and ring windings, and ran the package and repository checks.
Additional validation of vera-rubin's change on base 0c20329d and head e51817d0: two polygons with two disjoint interior holes were checked against centroids calculated by subtracting rectangle/triangle areas and moments.
An outer [0,0]–[12,10] rectangle with holes [1,1]–[3,4] and [8,6]–[11,9] has area 105 and centroid [83/14, 69/14]. Base returned [5.925143453312468, 4.923317683881065]; changing only the second hole's starting vertex changed it to [5.996781416176882, 4.937027707808564]. Head matches the expected center.
Across both fixtures, every cyclic ring start, three translations, and Feature/Geometry forms, head matched the independent oracle for all 672 diagnostic inputs within 1e-10. The 24 exterior-only controls passed on both revisions. Translation invariance also passed on base. Focused package checks passed on head (19 assertions plus type checking); the full repository suite was not run.
AI-assisted validation and draft.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
centerOfMassjoined polygon rings, adding artificial edges and returning the wrong centroid for polygons with holes.We sum each ring separately and subtract hole areas and moments regardless of winding.
We tested the reported example, both polygon input forms and ring windings, and ran the package and repository checks.
Fixes #3173
package.json.— ChipLab