Class TrigMathUtil

java.lang.Object
com.hypixel.hytale.math.util.TrigMathUtil

public class TrigMathUtil extends Object
Very fast lookup tables for cos, sin and atan2. The lookup tables are quite small so that they usually stay in the CPU cache and speed up calculation for very small precision loss.

Benchmark Mode Thr Count Sec Mean Mean error Units d.s.Benchmark.lookupAtan2Random thrpt 1 5 1 48531,643 1111,981 ops/ms d.s.Benchmark.lookupAtan2Static thrpt 1 5 1 4010948,016 241985,181 ops/ms d.s.Benchmark.lookupCosRandom thrpt 1 5 1 117573,283 2128,794 ops/ms d.s.Benchmark.lookupCosStatic thrpt 1 5 1 4096557,760 52240,139 ops/ms d.s.Benchmark.lookupSinRandom thrpt 1 5 1 118179,010 825,378 ops/ms d.s.Benchmark.lookupSinStatic thrpt 1 5 1 4096822,908 56183,272 ops/ms d.s.Benchmark.nativeAtan2Random thrpt 1 5 1 14675,699 124,458 ops/ms d.s.Benchmark.nativeAtan2Static thrpt 1 5 1 18076,954 63,463 ops/ms d.s.Benchmark.nativeCosRandom thrpt 1 5 1 65174,396 275,739 ops/ms d.s.Benchmark.nativeCosStatic thrpt 1 5 1 61510,934 471,859 ops/ms d.s.Benchmark.nativeSinRandom thrpt 1 5 1 57194,568 488,668 ops/ms d.s.Benchmark.nativeSinStatic thrpt 1 5 1 60888,364 749,274 ops/ms d.s.Benchmark.nothing thrpt 1 5 1 4123579,600 41883,722 ops/ms d.s.Benchmark.randomBaseline thrpt 1 5 1 117892,925 3754,653 ops/ms

Precision loss: TrigMathUtil#cos - max: 0.002301108092069626 - avg: 0.0006102947235925367 TrigMathUtil#sin: - max: 0.0023007746785879135 - avg: 0.0006102554030407974 TrigMathUtil#atan2: - max: 0.000010251998901367188 - avg: 0.0000039337042763789955

Since:
22.02.2017
  • Field Summary

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

    Modifier and Type
    Method
    Description
    static float
    asin(double d)
     
    static float
    atan(double d)
     
    static float
    atan2(double y, double x)
     
    static float
    atan2(float y, float x)
     
    static float
    cos(double radians)
     
    static float
    cos(float radians)
     
    static float
    sin(double radians)
     
    static float
    sin(float radians)
     

    Methods inherited from class Object

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

  • Method Details

    • sin

      public static float sin(float radians)
    • cos

      public static float cos(float radians)
    • sin

      public static float sin(double radians)
    • cos

      public static float cos(double radians)
    • atan2

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

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

      public static float atan(double d)
    • asin

      public static float asin(double d)