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,12 +41,16 @@ public class QuadRect {
}
public static boolean intersects(QuadRect a, QuadRect b) {
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.min(a.bottom, a.top) < Math.max(b.bottom, b.top)
&& Math.max(a.bottom, a.top) > Math.min(b.bottom, b.top);
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.min(a.bottom, a.top) <= Math.max(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() {
return (left + right) / 2;
}