#ifndef MATCHING_DISTANCE_BOX_H #define MATCHING_DISTANCE_BOX_H #include #include #include "common_util.h" namespace md { template struct Box { public: using Real = Real_; private: Point ll; Point ur; public: Box(Point ll = Point(), Point ur = Point()) :ll(ll), ur(ur) { } Box(Point center, Real width, Real height) : ll(Point(center.x - 0.5 * width, center.y - 0.5 * height)), ur(Point(center.x + 0.5 * width, center.y + 0.5 * height)) { } inline double width() const { return ur.x - ll.x; } inline double height() const { return ur.y - ll.y; } inline Point lower_left() const { return ll; } inline Point upper_right() const { return ur; } inline Point center() const { return Point((ll.x + ur.x) / 2, (ll.y + ur.y) / 2); } inline bool operator==(const Box& p) { return this->ll == p.ll && this->ur == p.ur; } std::vector refine() const; std::vector> corners() const; void translate(Real a); }; template std::ostream& operator<<(std::ostream& os, const Box& box); } // namespace md #include "box.hpp" #endif //MATCHING_DISTANCE_BOX_H