Class MathUtils


  • final class MathUtils
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  MathUtils.KahanSummator
      The implementation of the Kahan summation algorithm.
    • Constructor Summary

      Constructors 
      Constructor Description
      MathUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static double copySign​(double x, double y)
      Returns one value with the sign of another (like copysign).
      (package private) static double FMod​(double x, double y)
      C fmod function.
      (package private) static double lerp​(double start_, double end_, double t)
      Computes interpolation between two values, using the interpolation factor t.
      (package private) static void lerp​(double start_x, double start_y, double end_x, double end_y, double t, Point2D result)  
      (package private) static void lerp​(Point2D start_, Point2D end_, double t, Point2D result)
      Computes interpolation between two values, using the interpolation factor t.
      (package private) static double round​(double v)
      Rounds double to the closest integer value.
      (package private) static int sign​(double value)
      Calculates sign of the given value.
      (package private) static double sqr​(double v)  
      (package private) static double truncate​(double v)
      Rounds towards zero.
      • Methods inherited from class java.lang.Object

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

      • MathUtils

        MathUtils()
    • Method Detail

      • copySign

        static double copySign​(double x,
                               double y)
        Returns one value with the sign of another (like copysign).
      • sign

        static int sign​(double value)
        Calculates sign of the given value. Returns 0 if the value is equal to 0.
      • truncate

        static double truncate​(double v)
        Rounds towards zero.
      • FMod

        static double FMod​(double x,
                           double y)
        C fmod function.
      • round

        static double round​(double v)
        Rounds double to the closest integer value.
      • sqr

        static double sqr​(double v)
      • lerp

        static double lerp​(double start_,
                           double end_,
                           double t)
        Computes interpolation between two values, using the interpolation factor t. The interpolation formula is (end - start) * t + start. However, the computation ensures that t = 0 produces exactly start, and t = 1, produces exactly end. It also guarantees that for 0 <= t <= 1, the interpolated value v is between start and end.
      • lerp

        static void lerp​(Point2D start_,
                         Point2D end_,
                         double t,
                         Point2D result)
        Computes interpolation between two values, using the interpolation factor t. The interpolation formula is (end - start) * t + start. However, the computation ensures that t = 0 produces exactly start, and t = 1, produces exactly end. It also guarantees that for 0 <= t <= 1, the interpolated value v is between start and end.
      • lerp

        static void lerp​(double start_x,
                         double start_y,
                         double end_x,
                         double end_y,
                         double t,
                         Point2D result)