I have an image with two areas. I want to add now rectangles with a fixed size randomly into area2. The coordinate origin of the image is in the top-left corner. I have the cordinates of the area2. This are P1, P2, P3(0, y_max) and P4(x_max, y_max). Does anybody knows how to check, if a rectangle lies in this area? I can try to separate this area into 2 parts, a rectangle (rect_area) and a triangle (trangle_area). For the rect_area I can check with
bool intersects = ((rect_area & rect_random).area() > 0);
if the random rect lies inside the area. For the triangle I have found some complicated stuff like here: How to determine if a point is in a 2D triangle?
Does anybody knows an easier way to do that?