inline bool Intersects(const Rect<T> & r) const;
Intersects determines whether two rectangles intersect. The following expression is used to determine the result:
(y2 >= r.y1) && (r.y2 >= y1) && (r.x2 >= x1) && (x2 >= r.x1)
Parameters |
Description |
const Rect<T> & r |
A rectangle whose components are compared to those of the current rectangle in order to determine intersection. |
A Boolean value of 1 (true) if the rectangles intersect and 0 (false) if they do not.
Rect r1(0.0, 0.0, 7.0, 7.0); Rect r2(7.0, 0.0, 10.0, 7.0); Rect r3(2.0, 2.0, 8.0, 8.0); Rect r4(1.0, 1.0, 3.0, 3.0); Rect r5(8.0, 8.0, 9.0, 9.0); r1.Intersects(r2); // Returns 1 (true) because two rectangles intersect (the edges intersect) r1.Intersects(r3); // Returns 1 (true) because the two rectangles intersect r1.Intersects(r4); // Returns 1 (true) because the two rectangles intersect (r1 contains r4) r1.Intersects(r5); // Returns 0 (false) because the two rectangles do not intersect