public bool intersects(RectangleI R) { int[] p = R.points; bool contain = false; bool outside = false; int i = 0; while (i < p.Length) { if (containsPoint(p[i++], p[i++])) { contain = true; } else { outside = true; } } if (contain && outside) { return(true); } if (R.left < left && R.right > right) { //if ((top <= R.top && bottom <= R.top) || (top <= R.bottom && bottom <= R.bottom)) if ((top <= R.top && bottom >= R.top) || (top <= R.bottom && bottom >= R.bottom)) { return(true); } } if (R.top < top && R.bottom > bottom) { if ((left <= R.left && right >= R.left) || (left <= R.right && right >= R.right)) { return(true); } } /*if (R.left < left && R.right > right) * { * if ((top <= R.top && bottom <= R.top) || (top <= R.bottom && bottom <= R.bottom)) * { * return true; * } * } * if (R.top < top && R.bottom > bottom) * { * if ((left <= R.left && right <= R.left) || (left <= R.right && right <= R.right)) * { * return true; * } * }*/ return(false); }
public bool isTouching(RectangleI R) { if (R == null) { return(false); } int[] p = R.points; int i = 0; while (i < p.Length) { if (containsPoint(p[i++], p[i++])) { return(true); } } if (intersects(R)) { return(true); } return(false); }