Add intersects method to Rectangle4i

Added compare methods to MathHelper
This commit is contained in:
Chicken-Bomes committed 2013-12-11 17:34:04 +10:00
1 parent 699221214c
commit 8a777b265e
2 files changed
+16

No files matched your search

+10
View File
@@ -165,4 +165,14 @@ public class MathHelper
{
return (int) (d < 0 ? Math.floor(d) : Math.ceil(d));
}
public static int compare(int a, int b)
{
return a == b ? 0 : a < b ? -1 : 1;
}
public static int compare(double a, double b)
{
return a == b ? 0 : a < b ? -1 : 1;
}
}
+6
View File
@@ -39,4 +39,10 @@ public class Rectangle4i
{
return x <= px && px < x+w && y <= py && py < y+h;
}
public boolean intersects(Rectangle4i r)
{
return x <= r.x+r.w && r.x <= x+w &&
y <= r.y+r.h && r.y <= y+h;
}
}