Package org.oscim.utils
Class FastMath
java.lang.Object
org.oscim.utils.FastMath
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatabs(float value) static floatabsMax(float value1, float value2) static booleanabsMaxCmp(float value1, float value2, float cmp) test if any absolute value is greater than 'cmp'static booleanabsMaxCmp(int value1, int value2, int cmp) test if any absolute value is greater than 'cmp'static doubleclamp(double value, double min, double max) static floatclamp(float value, float min, float max) static intclamp(int value, int min, int max) static doubleclampDegree(double degree) Returns normalized degree in range of -180° to +180°static floatclampN(float value) static doubleclampRadian(double radian) Returns normalized radian in range of -PI to +PIstatic byteclampToByte(int value) static intlog2(int x) Integer version of log2(x)static floatpow(int x) Integer version of 2^xstatic floatround2(float value) static booleanwithinSquaredDist(float dx, float dy, float distance) static booleanwithinSquaredDist(int dx, int dy, int distance)
-
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)
-