Fix bug with quad rect

This commit is contained in:
Victor Shcherb 2021-03-18 14:30:34 +01:00
parent 4a357e6459
commit 025ee8e993

View file

@ -41,11 +41,15 @@ public class QuadRect {
} }
public static boolean intersects(QuadRect a, QuadRect b) { public static boolean intersects(QuadRect a, QuadRect b) {
return Math.min(a.left, a.right) < Math.max(b.left, b.right) return Math.min(a.left, a.right) <= Math.max(b.left, b.right)
&& Math.max(a.left, a.right) > Math.min(b.left, b.right) && Math.max(a.left, a.right) >= Math.min(b.left, b.right)
&& Math.min(a.bottom, a.top) < Math.max(b.bottom, b.top) && Math.min(a.bottom, a.top) <= Math.max(b.bottom, b.top)
&& Math.max(a.bottom, a.top) > Math.min(b.bottom, b.top); && Math.max(a.bottom, a.top) >= Math.min(b.bottom, b.top);
} }
public static boolean trivialOverlap(QuadRect a, QuadRect b) {
return intersects(a, b);
}
public double centerX() { public double centerX() {
return (left + right) / 2; return (left + right) / 2;