Class GeometryUtils


  • public final class GeometryUtils
    extends java.lang.Object
    Utility functions for geometry classes.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double EPSILON
      Small double for "equality" checks.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean equals​(double a, double b)
      Check if 2 double values are equal (withing EPSILON of each other).
      static boolean equals​(double x1, double y1, double x2, double y2)
      Check if 2 points equal.
      static double getAngle​(double x0, double y0, double x1, double y1)
      Calculate the angle between a line defined by 2 points.
      static boolean isNonZero​(double value)
      Checks if value is not within EPSILON of 0.0.
      static boolean isZero​(double value)
      Checks if value is within EPSILON of 0.0.
      static boolean lineContains​(double x0, double y0, double x1, double y1, double x2, double y2)
      Checks if point (x0, y0) is in line (x1, y1), (x2, y2).
      static boolean linesIntersect​(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
      Checks if line (x1, y1), (x2, y2) intersects the line (x3, y3), (x4, y4).
      static Shape toShape​(java.lang.Object value)
      Get a shape for value (if possible).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EPSILON

        public static final double EPSILON
        Small double for "equality" checks.
        See Also:
        Constant Field Values
    • Method Detail

      • isZero

        public static boolean isZero​(double value)
        Checks if value is within EPSILON of 0.0.
      • isNonZero

        public static boolean isNonZero​(double value)
        Checks if value is not within EPSILON of 0.0.
      • equals

        public static boolean equals​(double a,
                                     double b)
        Check if 2 double values are equal (withing EPSILON of each other).
      • equals

        public static boolean equals​(double x1,
                                     double y1,
                                     double x2,
                                     double y2)
        Check if 2 points equal.
      • lineContains

        public static boolean lineContains​(double x0,
                                           double y0,
                                           double x1,
                                           double y1,
                                           double x2,
                                           double y2)
        Checks if point (x0, y0) is in line (x1, y1), (x2, y2).
      • linesIntersect

        public static boolean linesIntersect​(double x1,
                                             double y1,
                                             double x2,
                                             double y2,
                                             double x3,
                                             double y3,
                                             double x4,
                                             double y4)
        Checks if line (x1, y1), (x2, y2) intersects the line (x3, y3), (x4, y4).
      • getAngle

        public static double getAngle​(double x0,
                                      double y0,
                                      double x1,
                                      double y1)
        Calculate the angle between a line defined by 2 points.
      • toShape

        public static Shape toShape​(java.lang.Object value)
        Get a shape for value (if possible).