Class MathHelper


  • public class MathHelper
    extends java.lang.Object
    Static functions for common math operations.
    • Constructor Summary

      Constructors 
      Constructor Description
      MathHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean almostEqualRelativeAndAbs​(float a, float b)
      Returns true if two floats are equal within a tolerance.
      static float clamp​(float value, float min, float max)
      Clamps a value between a minimum and maximum range.
      static float lerp​(float a, float b, float t)
      Linearly interpolates between a and b by a ratio.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MathHelper

        public MathHelper()
    • Method Detail

      • almostEqualRelativeAndAbs

        public static boolean almostEqualRelativeAndAbs​(float a,
                                                        float b)
        Returns true if two floats are equal within a tolerance. Useful for comparing floating point numbers while accounting for the limitations in floating point precision.
      • clamp

        public static float clamp​(float value,
                                  float min,
                                  float max)
        Clamps a value between a minimum and maximum range.
      • lerp

        public static float lerp​(float a,
                                 float b,
                                 float t)
        Linearly interpolates between a and b by a ratio.
        Parameters:
        a - the beginning value
        b - the ending value
        t - ratio between the two floats
        Returns:
        interpolated value between the two floats