Class MathUtils

java.lang.Object
dev.prozilla.pine.common.math.MathUtils

public final class MathUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    clamp(float value, float min, float max)
    Clamps a value between a min and a max value.
    static int
    clamp(int value, int min, int max)
    Clamps a value between a min and a max value.
    static float
    easeOutQuad(float time)
     
    static float
    lerp(float start, float end, float step)
    Linear interpolation between two values.
    static float
    remap(float value, float x, float y, float a, float b)
    Remaps a float value from one range to another.

    Methods inherited from class java.lang.Object

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

    • MathUtils

      public MathUtils()
  • Method Details

    • clamp

      public static float clamp(float value, float min, float max)
      Clamps a value between a min and a max value.
      Parameters:
      value - Value
      min - Min value
      max - Max value
      Returns:
      Clamped value
    • clamp

      public static int clamp(int value, int min, int max)
      Clamps a value between a min and a max value.
      Parameters:
      value - Value
      min - Min value
      max - Max value
      Returns:
      Clamped value
    • lerp

      public static float lerp(float start, float end, float step)
      Linear interpolation between two values.
      Parameters:
      start - Start value
      end - End value
      step - Amount to interpolate (between 0f and 1f)
      Returns:
      Interpolated value between start and value
    • remap

      public static float remap(float value, float x, float y, float a, float b) throws IllegalArgumentException
      Remaps a float value from one range to another.
      Parameters:
      value - The input float value to remap
      x - The lower bound of the original range
      y - The upper bound of the original range
      a - The lower bound of the target range
      b - The upper bound of the target range
      Returns:
      The remapped value in the range [a, b]
      Throws:
      IllegalArgumentException
    • easeOutQuad

      public static float easeOutQuad(float time)