Class MathUtils

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

public final class MathUtils extends Object
  • 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
    cubicBezier(float t, float p0, float p1, float p2, float p3)
    Calculates the value of a cubic Bézier function based on given control points.
    static boolean
     
    static float
    lerp(float start, float end, float step)
    Linear interpolation between two values.
    static double
    max(double[] values)
     
    static float
    max(float... values)
     
    static float
    min(float... values)
     
    static void
    normalize(double[] 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
  • 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
    • normalize

      public static void normalize(double[] values)
    • min

      public static float min(float... values)
    • max

      public static float max(float... values)
    • max

      public static double max(double[] values)
    • cubicBezier

      public static float cubicBezier(float t, float p0, float p1, float p2, float p3)
      Calculates the value of a cubic Bézier function based on given control points.
      Parameters:
      p0 - X coordinate of first control point
      p1 - Y coordinate of first control point
      p2 - X coordinate of second control point
      p3 - Y coordinate of second control point
    • isValidInteger

      public static boolean isValidInteger(String string)