Class FastMath

java.lang.Object
org.oscim.utils.FastMath

public class FastMath extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    abs(float value)
     
    static float
    absMax(float value1, float value2)
     
    static boolean
    absMaxCmp(float value1, float value2, float cmp)
    test if any absolute value is greater than 'cmp'
    static boolean
    absMaxCmp(int value1, int value2, int cmp)
    test if any absolute value is greater than 'cmp'
    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 double
    clampDegree(double degree)
    Returns normalized degree in range of -180° to +180°
    static float
    clampN(float value)
     
    static double
    clampRadian(double radian)
    Returns normalized radian in range of -PI to +PI
    static byte
    clampToByte(int value)
     
    static int
    log2(int x)
    Integer version of log2(x)
    static float
    pow(int x)
    Integer version of 2^x
    static float
    round2(float value)
     
    static boolean
    withinSquaredDist(float dx, float dy, float distance)
     
    static boolean
    withinSquaredDist(int dx, int dy, int distance)
     

    Methods inherited from class java.lang.Object

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

    • FastMath

      public FastMath()
  • Method Details

    • abs

      public static float abs(float value)
    • absMax

      public static float absMax(float value1, float value2)
    • absMaxCmp

      public static boolean absMaxCmp(float value1, float value2, float cmp)
      test if any absolute value is greater than 'cmp'
    • absMaxCmp

      public static boolean absMaxCmp(int value1, int value2, int cmp)
      test if any absolute value is greater than 'cmp'
    • clamp

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

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

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

      public static double clampDegree(double degree)
      Returns normalized degree in range of -180° to +180°
    • clampN

      public static float clampN(float value)
    • clampRadian

      public static double clampRadian(double radian)
      Returns normalized radian in range of -PI to +PI
    • clampToByte

      public static byte clampToByte(int value)
    • log2

      public static int log2(int x)
      Integer version of log2(x)

      from http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog

    • pow

      public static float pow(int x)
      Integer version of 2^x
    • round2

      public static float round2(float value)
    • withinSquaredDist

      public static boolean withinSquaredDist(int dx, int dy, int distance)
    • withinSquaredDist

      public static boolean withinSquaredDist(float dx, float dy, float distance)