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

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

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

    Modifier and Type
    Method
    Description
    static int
    compare(float left, float right)
    Gets an integer, that indicates the result of the comparison.
    static float
    confined(float low, float x, float high)
    Returns a float that is the confined value of x for two bounds.
    static boolean
    equals(float v1, float v2)
    Returns true, if the values are equal.
    static boolean
    lessThan(float left, float right)
    Returns true, is left comparand is less or equal to right comparand.
    static float
    max3(float v1, float v2, float v3)
    Gets a maximum float out of three values.
    static float
    min3(float v1, float v2, float v3)
    Gets a minumum float out of three values.
    static boolean
    moreThan(float left, float 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 float 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(float v1, float v2)
      Returns true, if the values are equal.

      Uses epsilon for the comparison.

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

      public static boolean moreThan(float left, float 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 - float to be compared
      right - float 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(float left, float 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 - float to be compared
      right - float 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(float left, float 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(float, float) and moreThan(float, float), because they are non-strict comparisons.

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

      public static float confined(float low, float x, float high)
      Returns a float 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 float to confine
      high - upper bound
      Returns:
      confined float
      Since:
      2.0.0
    • min3

      public static float min3(float v1, float v2, float v3)
      Gets a minumum float out of three values.
      Parameters:
      v1 - first float
      v2 - second float
      v3 - third float
      Returns:
      minimum float out of three values
      Since:
      2.0.0
    • max3

      public static float max3(float v1, float v2, float v3)
      Gets a maximum float out of three values.
      Parameters:
      v1 - first float
      v2 - second float
      v3 - third float
      Returns:
      maximum float out of three values
      Since:
      2.0.0