import android.graphics.Rect;
Rect r1 = Rect(10,10,20,20);
Rect r2 = Rect(20,20,30,30);
Rect.intersects(r1, r2); //returns FALSE
为什么?
在我的世界中,矩形应该相交于 20,20
最佳答案
因为 Rect.intersects(r1,r2)
执行以下操作,
public static boolean intersects(Rect a, Rect b) {
return a.left < b.right && b.left < a.right
&& a.top < b.bottom && b.top < a.bottom;
}
正如@clark 在评论中所描述的那样,- 将边缘视为严格小于/大于,不等于
关于java - 为什么 Rect(10,10,20,20) 不与 Rect(20,20,30,30) 相交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23089458/