Package org.joml

Class Math

java.lang.Object
org.joml.Math

public class Math extends Object
Contains fast approximations of some Math operations.

By default, Math methods will be used by all other JOML classes. In order to use the approximations in this class, start the JVM with the parameter -Djoml.fastmath.

There are two algorithms for approximating sin/cos:

  1. arithmetic polynomial approximation contributed by roquendm
  2. theagentd's linear interpolation variant of Riven's algorithm from http://www.java-gaming.org/
By default, the first algorithm is being used. In order to use the second one, start the JVM with -Djoml.sinLookup. The lookup table bit length of the second algorithm can also be adjusted for improved accuracy via -Djoml.sinLookup.bits=<n>, where <n> is the number of bits of the lookup table.
Author:
Kai Burjack
  • Field Summary

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    abs(double r)
     
    static float
    abs(float r)
     
    static int
    abs(int r)
     
    static double
    acos(double r)
     
    static float
    acos(float r)
     
    static double
    asin(double r)
     
    static float
    asin(float r)
     
    static double
    atan2(double y, double x)
     
    static float
    atan2(float y, float x)
     
    static double
    biLerp(double q00, double q10, double q01, double q11, double tx, double ty)
     
    static float
    biLerp(float q00, float q10, float q01, float q11, float tx, float ty)
     
    static double
    ceil(double v)
     
    static float
    ceil(float v)
     
    static double
    clamp(double a, double b, double val)
     
    static float
    clamp(float a, float b, float val)
     
    static int
    clamp(int a, int b, int val)
     
    static double
    cos(double rad)
     
    static float
    cos(float rad)
     
    static double
    cosFromSin(double sin, double angle)
     
    static float
    cosFromSin(float sin, float angle)
     
    static double
    exp(double a)
     
    static double
    floor(double v)
     
    static float
    floor(float v)
     
    static double
    fma(double a, double b, double c)
     
    static float
    fma(float a, float b, float c)
     
    static double
    invsqrt(double r)
     
    static float
    invsqrt(float r)
     
    static boolean
    isFinite(double d)
     
    static boolean
    isFinite(float f)
     
    static double
    lerp(double a, double b, double t)
     
    static float
    lerp(float a, float b, float t)
     
    static double
    max(double a, double b)
     
    static float
    max(float a, float b)
     
    static int
    max(int x, int y)
     
    static double
    min(double a, double b)
     
    static float
    min(float a, float b)
     
    static int
    min(int x, int y)
     
    static double
     
    static long
    round(double v)
     
    static int
    round(float v)
     
    static int
    roundHalfDown(double v)
     
    static int
    roundHalfDown(float v)
     
    static int
    roundHalfEven(double v)
     
    static int
    roundHalfEven(float v)
     
    static int
    roundHalfUp(double v)
     
    static int
    roundHalfUp(float v)
     
    static int
    roundUsing(double v, int mode)
     
    static int
    roundUsing(float v, int mode)
     
    static double
    safeAcos(double v)
     
    static float
    safeAcos(float v)
     
    static double
    safeAsin(double r)
     
    static float
    safeAsin(float r)
     
    static double
    signum(double v)
     
    static float
    signum(float v)
     
    static int
    signum(int v)
     
    static int
    signum(long v)
     
    static double
    sin(double rad)
     
    static float
    sin(float rad)
     
    static double
    sqrt(double r)
     
    static float
    sqrt(float r)
     
    static double
    tan(double r)
     
    static float
    tan(float r)
     
    static double
    toDegrees(double angles)
     
    static double
    toRadians(double angles)
     
    static float
    toRadians(float angles)
     
    static double
    triLerp(double q000, double q100, double q010, double q110, double q001, double q101, double q011, double q111, double tx, double ty, double tz)
     
    static float
    triLerp(float q000, float q100, float q010, float q110, float q001, float q101, float q011, float q111, float tx, float ty, float tz)
     

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • Math

      public Math()
  • Method Details

    • sin

      public static float sin(float rad)
    • sin

      public static double sin(double rad)
    • cos

      public static float cos(float rad)
    • cos

      public static double cos(double rad)
    • cosFromSin

      public static float cosFromSin(float sin, float angle)
    • cosFromSin

      public static double cosFromSin(double sin, double angle)
    • sqrt

      public static float sqrt(float r)
    • sqrt

      public static double sqrt(double r)
    • invsqrt

      public static float invsqrt(float r)
    • invsqrt

      public static double invsqrt(double r)
    • tan

      public static float tan(float r)
    • tan

      public static double tan(double r)
    • acos

      public static float acos(float r)
    • acos

      public static double acos(double r)
    • safeAcos

      public static float safeAcos(float v)
    • safeAcos

      public static double safeAcos(double v)
    • atan2

      public static float atan2(float y, float x)
    • atan2

      public static double atan2(double y, double x)
    • asin

      public static float asin(float r)
    • asin

      public static double asin(double r)
    • safeAsin

      public static float safeAsin(float r)
    • safeAsin

      public static double safeAsin(double r)
    • abs

      public static float abs(float r)
    • abs

      public static double abs(double r)
    • abs

      public static int abs(int r)
    • max

      public static int max(int x, int y)
    • min

      public static int min(int x, int y)
    • min

      public static double min(double a, double b)
    • min

      public static float min(float a, float b)
    • max

      public static float max(float a, float b)
    • max

      public static double max(double a, double b)
    • clamp

      public static float clamp(float a, float b, float val)
    • clamp

      public static double clamp(double a, double b, double val)
    • clamp

      public static int clamp(int a, int b, int val)
    • toRadians

      public static float toRadians(float angles)
    • toRadians

      public static double toRadians(double angles)
    • toDegrees

      public static double toDegrees(double angles)
    • floor

      public static double floor(double v)
    • floor

      public static float floor(float v)
    • ceil

      public static double ceil(double v)
    • ceil

      public static float ceil(float v)
    • round

      public static long round(double v)
    • round

      public static int round(float v)
    • exp

      public static double exp(double a)
    • isFinite

      public static boolean isFinite(double d)
    • isFinite

      public static boolean isFinite(float f)
    • fma

      public static float fma(float a, float b, float c)
    • fma

      public static double fma(double a, double b, double c)
    • roundUsing

      public static int roundUsing(float v, int mode)
    • roundUsing

      public static int roundUsing(double v, int mode)
    • lerp

      public static float lerp(float a, float b, float t)
    • lerp

      public static double lerp(double a, double b, double t)
    • biLerp

      public static float biLerp(float q00, float q10, float q01, float q11, float tx, float ty)
    • biLerp

      public static double biLerp(double q00, double q10, double q01, double q11, double tx, double ty)
    • triLerp

      public static float triLerp(float q000, float q100, float q010, float q110, float q001, float q101, float q011, float q111, float tx, float ty, float tz)
    • triLerp

      public static double triLerp(double q000, double q100, double q010, double q110, double q001, double q101, double q011, double q111, double tx, double ty, double tz)
    • roundHalfEven

      public static int roundHalfEven(float v)
    • roundHalfDown

      public static int roundHalfDown(float v)
    • roundHalfUp

      public static int roundHalfUp(float v)
    • roundHalfEven

      public static int roundHalfEven(double v)
    • roundHalfDown

      public static int roundHalfDown(double v)
    • roundHalfUp

      public static int roundHalfUp(double v)
    • random

      public static double random()
    • signum

      public static double signum(double v)
    • signum

      public static float signum(float v)
    • signum

      public static int signum(int v)
    • signum

      public static int signum(long v)