Uploaded image for project: 'Apache Commons Geometry'
  1. Apache Commons Geometry
  2. GEOMETRY-11

Replace tolerance with GeometryContext

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Closed
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: None

      Description

      All of the partitioning-related concrete classes (ex: Plane, PolygonsSet, PolyhedronsSet, etc) use a double value named tolerance in order to address issues with floating point accuracy. For example, when determining if a point lies in a plane, the point does not need to lie exactly on the plane but just be within +- tolerance distance from it. Code testing values against each other using this toleranceĀ isĀ repeated throughout the code base (ex: x >= y - tolerance). We should abstract the concept of the tolerance into a GeometryContext class and provide methods for testing values against each other using the tolerance. This will reduce the chance of bugs and will also allow for more sophisticated handling of floating point accuracy later on.

      The GeometryContext class would be similar to the MathContext class used by BigDecimal but would contain the logic for making comparisons in addition to the configuration for the comparisons.

      public class GeometryContext {
         public GeometryContext(tolerance){...}
      
         public double getTolerance(){ ... }
      
         // return -1, 0, +1
         public int compare(double a, double b) { ... }
      }

      Pull request: https://github.com/apache/commons-geometry/pull/22

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                mattjuntunen Matt Juntunen
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m