Class MathUtil

java.lang.Object
wtf.choco.arrows.util.MathUtil

public final class MathUtil
extends Object
Miscellaneous math utility methods.
Author:
Parker Hawke - Choco
  • Method Summary

    Modifier and Type Method Description
    static double clamp​(double value, double min, double max)
    Clamp a value between a minimum and maximum value.
    static float clamp​(float value, float min, float max)
    Clamp a value between a minimum and maximum value.
    static int clamp​(int value, int min, int max)
    Clamp a value between a minimum and maximum value.

    Methods inherited from class java.lang.Object

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

    • clamp

      public static int clamp​(int value, int min, int max)
      Clamp a value between a minimum and maximum value. If the value exceeds the specified bounds, it will be limited to its exceeding bound.
      Parameters:
      value - the value to clamp
      min - the minimum allowed value
      max - the maximum allowed value
      Returns:
      the clamped value. Itself if the boundaries were not exceeded
    • clamp

      public static double clamp​(double value, double min, double max)
      Clamp a value between a minimum and maximum value. If the value exceeds the specified bounds, it will be limited to its exceeding bound.
      Parameters:
      value - the value to clamp
      min - the minimum allowed value
      max - the maximum allowed value
      Returns:
      the clamped value. Itself if the boundaries were not exceeded
    • clamp

      public static float clamp​(float value, float min, float max)
      Clamp a value between a minimum and maximum value. If the value exceeds the specified bounds, it will be limited to its exceeding bound.
      Parameters:
      value - the value to clamp
      min - the minimum allowed value
      max - the maximum allowed value
      Returns:
      the clamped value. Itself if the boundaries were not exceeded