use faster Math.abs utility, cleanups, comments

This commit is contained in:
Hannes Janetzek
2013-02-10 12:17:39 +01:00
parent 429b8a98d7
commit 32ba8bbae0
2 changed files with 44 additions and 25 deletions

View File

@@ -54,4 +54,18 @@ public class FastMath {
return (pow > 0 ? (1 << pow) : (1.0f / (1 << -pow)));
}
public static float abs(float value){
return value < 0 ? -value : value;
}
public static float absMax(float value1, float value2){
float a1 = value1 < 0 ? -value1 : value1;
float a2 = value2 < 0 ? -value2 : value2;
return a2 < a1 ? a1 : a2;
}
public static boolean absMaxCmp(float value1, float value2, float cmp){
return value1 < -cmp || value1 > cmp || value2 < -cmp || value2 > cmp;
}
}