Package 

Class MathUtils


  • 
    public class MathUtils
    
                        

    A utility class providing functions useful for common mathematical operations.

    • Method Summary

      Modifier and Type Method Description
      static float clamp(float value, float min, float max) This method takes a numerical value and ensures it fits in a given numerical range.
      static double clamp(double value, double min, double max) This method takes a numerical value and ensures it fits in a given numerical range.
      static int clamp(int value, int min, int max) This method takes a numerical value and ensures it fits in a given numerical range.
      static long clamp(long value, long min, long max) This method takes a numerical value and ensures it fits in a given numerical range.
      • Methods inherited from class java.lang.Object

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

      • clamp

         static float clamp(float value, float min, float max)

        This method takes a numerical value and ensures it fits in a given numerical range. If thenumber is smaller than the minimum required by the range, then the minimum of the range willbe returned. If the number is higher than the maximum allowed by the range then the maximumof the range will be returned.

        Parameters:
        value - the value to be clamped.
        min - minimum resulting value.
        max - maximum resulting value.
      • clamp

         static double clamp(double value, double min, double max)

        This method takes a numerical value and ensures it fits in a given numerical range. If thenumber is smaller than the minimum required by the range, then the minimum of the range willbe returned. If the number is higher than the maximum allowed by the range then the maximumof the range will be returned.

        Parameters:
        value - the value to be clamped.
        min - minimum resulting value.
        max - maximum resulting value.
      • clamp

         static int clamp(int value, int min, int max)

        This method takes a numerical value and ensures it fits in a given numerical range. If thenumber is smaller than the minimum required by the range, then the minimum of the range willbe returned. If the number is higher than the maximum allowed by the range then the maximumof the range will be returned.

        Parameters:
        value - the value to be clamped.
        min - minimum resulting value.
        max - maximum resulting value.
      • clamp

         static long clamp(long value, long min, long max)

        This method takes a numerical value and ensures it fits in a given numerical range. If thenumber is smaller than the minimum required by the range, then the minimum of the range willbe returned. If the number is higher than the maximum allowed by the range then the maximumof the range will be returned.

        Parameters:
        value - the value to be clamped.
        min - minimum resulting value.
        max - maximum resulting value.