Class MathUtil

java.lang.Object
xyz.gmitch215.socketmc.util.math.MathUtil

public final class MathUtil extends Object
A utility class for replicating math operations used in Minecraft.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    lerp(double delta, double start, double end)
    Method for linear interpolation of doubles
    static float
    lerp(float delta, float start, float end)
    Method for linear interpolation of floats
    static int
    positiveCeilDiv(int x, int y)
    Returns the smallest (closest to negative infinity) int value that is greater than or equal to the algebraic quotient.
    static int
    roundToward(int value, int factor)
    Rounds the given value up to a multiple of factor.

    Methods inherited from class java.lang.Object

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

    • lerp

      public static float lerp(float delta, float start, float end)
      Method for linear interpolation of floats
      Parameters:
      delta - A value usually between 0 and 1 that indicates the percentage of the lerp. (0 will give the start value and 1 will give the end value)
      start - Start value for the lerp
      end - End value for the lerp
    • lerp

      public static double lerp(double delta, double start, double end)
      Method for linear interpolation of doubles
      Parameters:
      delta - A value usually between 0 and 1 that indicates the percentage of the lerp. (0 will give the start value and 1 will give the end value)
      start - Start value for the lerp
      end - End value for the lerp
    • roundToward

      public static int roundToward(int value, int factor)
      Rounds the given value up to a multiple of factor.
      Returns:
      The smallest integer multiple of factor that is greater than or equal to the value
    • positiveCeilDiv

      public static int positiveCeilDiv(int x, int y)
      Returns the smallest (closest to negative infinity) int value that is greater than or equal to the algebraic quotient.
      See Also: