diff options
author | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-03-09 16:43:07 +0100 |
---|---|---|
committer | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-03-09 16:43:07 +0100 |
commit | ca4222ab40f1c6c0d17fb7d43539aa675f640976 (patch) | |
tree | e2a91037ac1d9e8895eafbab54c1c11f0b257c85 /matching/include/box.hpp | |
parent | 7fb44351b487c64f23066a428089ef14a95b4176 (diff) | |
parent | 14e91d6c3ad81a1ec763d75a28f20fb689e5166e (diff) |
Merge README
Diffstat (limited to 'matching/include/box.hpp')
-rw-r--r-- | matching/include/box.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/matching/include/box.hpp b/matching/include/box.hpp new file mode 100644 index 0000000..f551d84 --- /dev/null +++ b/matching/include/box.hpp @@ -0,0 +1,52 @@ +namespace md { + + template<class Real> + std::ostream& operator<<(std::ostream& os, const Box<Real>& box) + { + os << "Box(lower_left = " << box.lower_left() << ", upper_right = " << box.upper_right() << ")"; + return os; + } + + template<class Real> + void Box<Real>::translate(Real a) + { + ll.x += a; + ll.y += a; + ur.x += a; + ur.y += a; + } + + template<class Real> + std::vector<Box<Real>> Box<Real>::refine() const + { + std::vector<Box<Real>> result; + +// 1 | 2 +// 0 | 3 + + Point<Real> new_ll = lower_left(); + Point<Real> new_ur = center(); + result.emplace_back(new_ll, new_ur); + + new_ll.y = center().y; + new_ur.y = ur.y; + result.emplace_back(new_ll, new_ur); + + new_ll = center(); + new_ur = upper_right(); + result.emplace_back(new_ll, new_ur); + + new_ll.y = ll.y; + new_ur.y = center().y; + result.emplace_back(new_ll, new_ur); + + return result; + } + + template<class Real> + std::vector<Point<Real>> Box<Real>::corners() const + { + return {ll, Point<Real>(ll.x, ur.y), ur, Point<Real>(ur.x, ll.y)}; + }; + +} |