Class MathUtil

java.lang.Object
org.jhotdraw8.base.util.MathUtil

public class MathUtil extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    clamp(double value, double min, double max)
    Clamps a value to the given range.
    static float
    clamp(float value, float min, float max)
    Clamps a value to the given range.
    static int
    clamp(int value, int min, int max)
    Clamps a value to the given range.
    static long
    clamp(long value, long min, long max)
    Clamps a value to the given range.

    Methods inherited from class java.lang.Object

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

    • clamp

      public static long clamp(long value, long min, long max)
      Clamps a value to the given range.
      Parameters:
      value - the value
      min - the lower bound of the range
      max - the upper bound of the range
      Returns:
      the constrained value
    • clamp

      public static double clamp(double value, double min, double max)
      Clamps a value to the given range.
      Parameters:
      value - the value
      min - the lower bound of the range
      max - the upper bound of the range
      Returns:
      the constrained value
    • clamp

      public static float clamp(float value, float min, float max)
      Clamps a value to the given range.
      Parameters:
      value - the value
      min - the lower bound of the range
      max - the upper bound of the range
      Returns:
      the constrained value
    • clamp

      public static int clamp(int value, int min, int max)
      Clamps a value to the given range.
      Parameters:
      value - the value
      min - the lower bound of the range
      max - the upper bound of the range
      Returns:
      the constrained value