Class MathUtils

java.lang.Object
io.karma.kommons.math.MathUtils

@API(status=STABLE) public final class MathUtils extends Object
Shared utility functions for common math operations which didn't make it into Java's Math class.
Since:
02/02/2022
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte
    clamp(byte value, byte min, byte max)
     
    static double
    clamp(double value, double min, double max)
     
    static float
    clamp(float value, float min, float max)
     
    static int
    clamp(int value, int min, int max)
     
    static long
    clamp(long value, long min, long max)
     
    static short
    clamp(short value, short min, short max)
     
    static float[]
    cross(float x1, float y1, float z1, float x2, float y2, float z2)
     
    static double
    dot(double x1, double y1, double x2, double y2)
     
    static double
    dot(double x1, double y1, double z1, double x2, double y2, double z2)
     
    static double
    dot(double x1, double y1, double z1, double w1, double x2, double y2, double z2, double w2)
     
    static float
    dot(float x1, float y1, float x2, float y2)
     
    static float
    dot(float x1, float y1, float z1, float x2, float y2, float z2)
     
    static float
    dot(float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2)
     
    static double
    fract(double value)
     
    static float
    fract(float value)
     
    static int
    getSmallestMultiple(int... values)
    Determines the smallest multiple of the given values.
    static byte
    lerp(byte start, byte end, float factor)
     
    static double
    lerp(double start, double end, float factor)
     
    static float
    lerp(float start, float end, float factor)
     
    static int
    lerp(int start, int end, float factor)
     
    static long
    lerp(long start, long end, float factor)
     
    static short
    lerp(short start, short end, float factor)
     
    static double
    mix(double x, double y, float a)
     
    static float
    mix(float x, float y, float a)
     

    Methods inherited from class java.lang.Object

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

  • Method Details

    • clamp

      public static byte clamp(byte value, byte min, byte max)
    • clamp

      public static short clamp(short value, short min, short max)
    • clamp

      public static int clamp(int value, int min, int max)
    • clamp

      public static long clamp(long value, long min, long max)
    • clamp

      public static float clamp(float value, float min, float max)
    • clamp

      public static double clamp(double value, double min, double max)
    • lerp

      public static byte lerp(byte start, byte end, float factor)
    • lerp

      public static short lerp(short start, short end, float factor)
    • lerp

      public static int lerp(int start, int end, float factor)
    • lerp

      public static long lerp(long start, long end, float factor)
    • lerp

      public static float lerp(float start, float end, float factor)
    • lerp

      public static double lerp(double start, double end, float factor)
    • fract

      public static float fract(float value)
    • fract

      public static double fract(double value)
    • mix

      public static float mix(float x, float y, float a)
    • mix

      public static double mix(double x, double y, float a)
    • dot

      public static float dot(float x1, float y1, float x2, float y2)
    • dot

      public static float dot(float x1, float y1, float z1, float x2, float y2, float z2)
    • dot

      public static float dot(float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2)
    • dot

      public static double dot(double x1, double y1, double x2, double y2)
    • dot

      public static double dot(double x1, double y1, double z1, double x2, double y2, double z2)
    • dot

      public static double dot(double x1, double y1, double z1, double w1, double x2, double y2, double z2, double w2)
    • cross

      public static float[] cross(float x1, float y1, float z1, float x2, float y2, float z2)
    • getSmallestMultiple

      public static int getSmallestMultiple(int... values)
      Determines the smallest multiple of the given values.
      Parameters:
      values - The values to calculate the smalles multiple of.
      Returns:
      The smallest multiple of the given values.