java.lang.Object
io.github.shimeoki.jfx.rasterization.Doubles

public final class Doubles extends Object
Class for some operations on doubles using a fixed epsilon value.
Since:
2.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Epsilon that is used for comparison operations in this class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    compare(double left, double right)
    Gets an integer, that indicates the result of the comparison.
    static double
    confined(double low, double x, double high)
    Returns a double that is the confined value of x for two bounds.
    static boolean
    equals(double v1, double v2)
    Returns true, if the values are equal.
    static boolean
    lessThan(double left, double right)
    Returns true, is left comparand is less or equal to right comparand.
    static boolean
    moreThan(double left, double right)
    Returns true, is left comparand is more or equal to right comparand.

    Methods inherited from class java.lang.Object

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

    • EPSILON

      public static final double EPSILON
      Epsilon that is used for comparison operations in this class.

      EPSILON is almost equal to zero, so all functions try to get zero and compare it to the epsilon.

      Since:
      2.0.0
      See Also:
  • Method Details

    • equals

      public static boolean equals(double v1, double v2)
      Returns true, if the values are equal.

      Uses epsilon for the comparison.

      Parameters:
      v1 - first double
      v2 - second double
      Returns:
      true, if the values are equal; false otherwise
      Since:
      2.0.0
    • moreThan

      public static boolean moreThan(double left, double right)
      Returns true, is left comparand is more or equal to right comparand.

      Uses epsilon for the comparison. Because of that, comparison is non-strict.

      Should give the same result as lessThan with swapped comparands, if they are not equal. If they are equal, both functions should return true.

      Parameters:
      left - double to be compared
      right - double it is compared to
      Returns:
      true, if left is more than or equals right; false otherwise
      Since:
      2.0.0
      See Also:
    • lessThan

      public static boolean lessThan(double left, double right)
      Returns true, is left comparand is less or equal to right comparand.

      Uses epsilon for the comparison. Because of that, comparison is non-strict.

      Should give the same result as moreThan with swapped comparands, if they are not equal. If they are equal, both functions should return true.

      Parameters:
      left - double to be compared
      right - double it is compared to
      Returns:
      true, if left is less than or equals right; false otherwise
      Since:
      2.0.0
      See Also:
    • compare

      public static int compare(double left, double right)
      Gets an integer, that indicates the result of the comparison.

      If both values are equal, then 0 is returned.

      If left is more than right, then 1 is returned.

      Otherwise, -1 is returned.

      It does not function as shorthand syntax for lessThan(double, double) and moreThan(double, double), because they are non-strict comparisons.

      Parameters:
      left - double to be compared
      right - double it is compared to
      Returns:
      0, 1 or -1
      Since:
      2.0.0
      See Also:
    • confined

      public static double confined(double low, double x, double high)
      Returns a double that is the confined value of x for two bounds.

      If x is less than low, then low is returned.

      If x is more than high, then high is returned.

      Otherwise x is returned.

      Parameters:
      low - lower bound
      x - target double to confine
      high - upper bound
      Returns:
      confined double
      Since:
      2.0.0