Class Maths


  • public final class Maths
    extends java.lang.Object
    Small numeric helpers.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double clamp​(double value, double min, double max)
      Constrains value to the inclusive range [min, max].
      static int clamp​(int value, int min, int max)
      Constrains value to the inclusive range [min, max].
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • clamp

        public static int clamp​(int value,
                                int min,
                                int max)
        Constrains value to the inclusive range [min, max].
        Parameters:
        value - the value to constrain
        min - the lower bound, inclusive
        max - the upper bound, inclusive
        Returns:
        the clamped value
      • clamp

        public static double clamp​(double value,
                                   double min,
                                   double max)
        Constrains value to the inclusive range [min, max].
        Parameters:
        value - the value to constrain
        min - the lower bound, inclusive
        max - the upper bound, inclusive
        Returns:
        the clamped value