Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- class Rect {
- /// Member variable top left (x1, y1) and bottom-right (x2, y2) points
- float x1, y1, x2, y2;
- public:
- /// Constructors
- Rect();
- Rect(float x1, float y1, float x2, float y2);
- float getX1() const; /// Get x1
- float getY1() const; /// Get y1
- float getX2() const; /// Get x2
- float getY2() const; /// Get x2
- void setX1(float val); /// Set x1
- void setY1(float val); /// Set y1
- void setX2(float val); /// Set x2
- void setY2(float val); /// Set y2
- float width() const; /// Get width
- float height() const; /// Get height
- float area() const; /// Get area
- float aspect() const; /// Get aspect ratio: height / width
- /// Check whether the rectangle overlaps with the other rectangle
- bool overlaps(const Rect &other) const;
- /// Expand current rectangle to include the point (x, y).
- void include(float x, float y);
- /// Expand current rectangle to include the the other rectangle.
- void include(const Rect &other);
- /// Check if the current rectangle includes the point (x, y)
- bool includes(float x,float y);
- /// Check if the current rectangle includes the other rectangle
- bool includes(const Rect &other);
- /// Expand the dimensions of current rectangle by the specified values
- void dilate(float dx0, float dy0, float dx1, float dy1);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement