add FastMath.withinSquaredDistance()

This commit is contained in:
Hannes Janetzek 2014-01-25 10:06:10 +01:00
parent 7ae8ee4405
commit 4351ff82fc

View File

@ -96,4 +96,12 @@ public class FastMath {
public static boolean absMaxCmp(int value1, int value2, int cmp) {
return value1 < -cmp || value1 > cmp || value2 < -cmp || value2 > cmp;
}
public static boolean withinSquaredDist(int dx, int dy, int distance) {
return dx * dx + dy * dy < distance;
}
public static boolean withinSquaredDist(float dx, float dy, float distance) {
return dx * dx + dy * dy < distance;
}
}