I am stuck in this assignment where I need to find intersection of squares. So far I created a vector of squares( there are only 3 squares necessary). I input the value for width and height, which are the same, because the shape is a square.
There is Rectangle Class:
struct Rectangle : Shape {
Rectangle(Point xy, int ww, int hh) : w(ww), h(hh)
{
add(xy);
if (h<=0 || w<=0) error("Bad rectangle: non-positive side");
}
Rectangle(Point x, Point y) : w(y.x-x.x), h(y.y-x.y)
{
add(x);
if (h<=0 || w<=0) error("Bad rectangle: non-positive width or height");
}
void draw_lines() const;
int height() const { return h; }
int width() const { return w; }
private:
int h; // height
int w; // width
};
Based on this class I need to write a code how three rectangles intersect and create objects out those intersection. For instance, if two rectangles intersect each other, another rectangle is created(it is basically rectangle intersection)