Class RegionBSPTree3D.RegionSizePropertiesVisitor

java.lang.Object
org.apache.commons.geometry.euclidean.threed.RegionBSPTree3D.RegionSizePropertiesVisitor
All Implemented Interfaces:
BSPTreeVisitor<Vector3D,RegionBSPTree3D.RegionNode3D>
Enclosing class:
RegionBSPTree3D

private static final class RegionBSPTree3D.RegionSizePropertiesVisitor extends Object implements BSPTreeVisitor<Vector3D,RegionBSPTree3D.RegionNode3D>
Visitor for computing geometric properties for 3D BSP tree instances. The volume of the region is computed using the equation V = (1/3)*ΣF[(CF⋅NF)*area(F)], where F represents each face in the region, CF represents the centroid of the face, and NF represents the normal of the face. (More details can be found in the article here.) This essentially splits up the region into pyramids with a 2D face forming the base of each pyramid. The centroid is computed in a similar way. The centroid of each pyramid is calculated using the fact that it is located 3/4 of the way along the line from the apex to the base. The region centroid then becomes the volume-weighted average of these pyramid centers.
See Also:
  • Field Details

    • volumeSum

      private double volumeSum
      Accumulator for boundary volume contributions.
    • sumX

      private double sumX
      Centroid contribution x coordinate accumulator.
    • sumY

      private double sumY
      Centroid contribution y coordinate accumulator.
    • sumZ

      private double sumZ
      Centroid contribution z coordinate accumulator.
  • Constructor Details

    • RegionSizePropertiesVisitor

      private RegionSizePropertiesVisitor()
  • Method Details

    • visit

      Visit a node in a BSP tree. This method is called for both internal nodes and leaf nodes.
      Specified by:
      visit in interface BSPTreeVisitor<Vector3D,RegionBSPTree3D.RegionNode3D>
      Parameters:
      node - the node being visited
      Returns:
      the result of the visit operation
    • getRegionSizeProperties

      public AbstractRegionBSPTree.RegionSizeProperties<Vector3D> getRegionSizeProperties()
      Return the computed size properties for the visited region.
      Returns:
      the computed size properties for the visited region.
    • addBoundaryContribution

      private void addBoundaryContribution(HyperplaneSubset<Vector3D> boundary, boolean reverse)
      Add the contribution of the given node cut boundary. If reverse is true, the volume of the contribution is reversed before being added to the total.
      Parameters:
      boundary - node cut boundary
      reverse - if true, the boundary contribution is reversed before being added to the total.