Contains determines whether a geometric shape exists completely inside of the local rectangle. The following expression is used to determine the result:
([x, pt.x, r.x2] <= x2) && ([x, pt.x, r.x1]>= x1) && ([y, pt.y, r.y2] <= y2) && ([y, pt.y, r.y1] >= y1)
Parameters |
Description |
T x |
A value that is compared to the x2 and x1 components of the local rectangle. |
T y |
A value that is compared to the y2 and y1 components of the local rectangle. |
const Point<T> & pt |
A point whose x component is compared to the x2 and x1 components of the local rectangle, and whose y component is compared to the y1 and y2. |
const Rect<T> & r |
A rectangle whose components are compared to those of the local rectangle. |
A Boolean value of 1 (true) if the geometric shape exists completely inside of the local rectangle, and 0 (false) otherwise.
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); Point pt(3.0, 4.0); r1.Contains(r2); // Returns 0 (false) because r1 does not contain r2 r1.Contains(r3); // Returns 0 (false) because r1 does not fully contain r3 r1.Contains(r4); // Returns 1 (true) because r1 contains r4 r1.Contains(r5); // Returns 0 (false) because the two rectangles do not intersect r1.Contains(2, 3); // Returns 1 (true) because r1 contains the point (2, 3) r1.Contains(pt); // Returns 1 (true) because r1 contains pt