MATH-1442: adding javadocs to PolyhedronsSet.FacetContributionVisitor
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/dc0465e8 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/dc0465e8 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/dc0465e8 Branch: refs/heads/master Commit: dc0465e864d7eace765434834d19575a106dbf64 Parents: 31e4a6d Author: darkma773r <[email protected]> Authored: Wed Jan 24 22:08:18 2018 -0500 Committer: darkma773r <[email protected]> Committed: Wed Jan 24 22:08:18 2018 -0500 ---------------------------------------------------------------------- .../geometry/euclidean/threed/PolyhedronsSet.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/dc0465e8/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java index 4459d34..d7f846a 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java @@ -398,19 +398,31 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { */ private static class FacetsContributionVisitor implements BSPTreeVisitor<Euclidean3D> { + /** Accumulator for facet volume contributions. */ private double volumeSum; + + /** Accumulator for barycenter contributions. */ private Cartesian3D barycenterSum = Cartesian3D.ZERO; + /** Returns the total computed size (ie, volume) of the polyhedron. + * This value will be negative if the polyhedron is "inside-out", meaning + * that it has a finite outside surrounded by an infinite inside. + * @return + */ public double getSize() { // apply the 1/3 pyramid volume scaling factor return volumeSum / 3.0; } + /** Returns the computed barycenter. This is the volume-weighted average + * of contributions from all facets. All coordinates will be NaN if the + * region is infinite. + * @return + */ public Cartesian3D getBarycenter() { // Since the volume we used when adding together the facet contributions // was 3x the actual pyramid size, we'll multiply by 1/4 here instead - // of 3/4. This will make the overall polyhedron volume the weighted - // average of the pyramid barycenters. + // of 3/4 to adjust for the actual barycenter position in each pyramid. return new Cartesian3D(1.0 / (4 * getSize()), barycenterSum); }
