MCPcopy Create free account
hub / github.com/PDAL/PDAL / BBox

Class BBox

pdal/QuadIndex.cpp:47–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 using namespace pdal;
46
47 struct BBox
48 {
49 BBox(Point minimum, Point maximum)
50 : minimum(minimum)
51 , maximum(maximum)
52 , center(minimum.x + (maximum.x - minimum.x) / 2,
53 minimum.y + (maximum.y - minimum.y) / 2)
54 , halfWidth(center.x - minimum.x)
55 , halfHeight(center.y - minimum.y)
56 { }
57
58 BBox(const BBox& other)
59 : minimum(other.minimum)
60 , maximum(other.maximum)
61 , center(other.center)
62 , halfWidth(other.halfWidth)
63 , halfHeight(other.halfHeight)
64 { }
65
66 // Returns true if this BBox shares any area in common with another.
67 bool overlaps(const BBox& other) const
68 {
69 return
70 std::abs(center.x - other.center.x) <
71 halfWidth + other.halfWidth &&
72 std::abs(center.y - other.center.y) <
73 halfHeight + other.halfHeight;
74 }
75
76 bool overlaps(
77 const double xBegin,
78 const double xEnd,
79 const double yBegin,
80 const double yEnd) const
81 {
82 const BBox other(
83 Point(xBegin, yBegin),
84 Point(xEnd, yEnd));
85
86 return overlaps(other);
87 }
88
89 // Returns true if the requested point is contained within this BBox.
90 bool contains(const Point& p) const
91 {
92 return p.x >= minimum.x && p.y >= minimum.y &&
93 p.x < maximum.x && p.y < maximum.y;
94 }
95
96 const Point minimum;
97 const Point maximum;
98
99 // Pre-calculate these properties, rather than exposing functions to
100 // calculate them on-demand, due to the large number of times that
101 // these will be needed when querying the quad tree.
102 const Point center;
103 const double halfWidth;
104 const double halfHeight;

Callers 3

addPointMethod · 0.85
QImplMethod · 0.85
getPointsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected