Added centroid method#4173
Conversation
mahrud
left a comment
There was a problem hiding this comment.
Thanks! This is great, I left a few comments ranging from typos to just some FYIs in case you're interested.
| "minimalNonFaces", | ||
| "stanleyReisnerRing" | ||
| "stanleyReisnerRing", | ||
| "centroid" |
There was a problem hiding this comment.
Sidenote: this way next time someone adds a function they don't edit two lines, which can sometimes avoid merge conflicts.
| "centroid" | |
| "centroid", |
| centroid | ||
| (centroid,Polyhedron) | ||
| Headline | ||
| Computes the centroid or barycenter of a polyhedron. |
There was a problem hiding this comment.
Following the convention in the rest of the package:
| Computes the centroid or barycenter of a polyhedron. | |
| computes the centroid or barycenter of a polyhedron |
There was a problem hiding this comment.
At least in Polyhedra/documentation/documentation.m2, it looks like the main convention is a capitalized first letter and the phrase ends with a period.
There was a problem hiding this comment.
Huh, that's definitely not the suggestion of the style guide, but from the toc it seems only a few nodes are like that.
| :Matrix | ||
| Description | ||
| Text | ||
| The centroid a polyhedron is the center of mass of the polyhedron. |
There was a problem hiding this comment.
| The centroid a polyhedron is the center of mass of the polyhedron. | |
| The centroid of a polyhedron is the center of mass of the polyhedron. |
| Caveat | ||
| The polyhedron must be compact. |
There was a problem hiding this comment.
Others can correct me if I'm mistaken, but I believe this is meant for the caveats of the algorithm or implementation, not assumptions of the definition. You could mention in the Inputs section that P must be compact.
| sum for delta in barycentricTriangulation P list ( | ||
| barycenter := (sum delta) / #delta; | ||
| (volume convexHull delta / totalVolume) * barycenter | ||
| ) |
There was a problem hiding this comment.
This is totally fine as as, but FYI, this also works:
| sum for delta in barycentricTriangulation P list ( | |
| barycenter := (sum delta) / #delta; | |
| (volume convexHull delta / totalVolume) * barycenter | |
| ) | |
| sum(barycentricTriangulation P, delta -> ( | |
| barycenter := (sum delta) / #delta; | |
| (volume convexHull delta / totalVolume) * barycenter | |
| ) | |
| ) |
The advantage (which is negligible here) is that unlike this way we don't need to construct a list and then sum it, we just sum as we go.
There was a problem hiding this comment.
Didn't realize sum could do this, thanks!
Added a method to compute the centroid of a polyhedron. This implements the feature requested in #4172.