/
aabb.hpp
51 lines (38 loc) · 932 Bytes
/
aabb.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// axis aligned bounding box
#ifndef AABB_HPPPP
#define AABB_HPPPP
#include "ga.hpp"
class Aabb {
Point<> _a;
Point<> _b;
public:
Aabb() {}
Aabb(const Point<> &llo, const Point<> &uup) {
lower(llo);
upper(uup);
}
// getters
inline Point<>& a() { return _a; }
inline Point<>& b() { return _b; }
inline const Point<>& a() const { return _a; }
inline const Point<>& b() const { return _b; }
// setters
inline Aabb& a(const Point<> &aa) {
mov(_a, aa); return *this;
}
inline Aabb& b(const Point<> &bb) {
mov(_b, bb); return *this;
}
// new interface
inline Point<>& lower() { return _a; }
inline Point<>& upper() { return _b; }
inline const Point<>& lower() const { return _a; }
inline const Point<>& upper() const { return _b; }
inline Aabb& lower(const Point<> &aa) {
mov(_a, aa); return *this;
}
inline Aabb& upper(const Point<> &bb) {
mov(_b, bb); return *this;
}
};
#endif