26 namespace perception {
36 Rect(
const T &x_in,
const T &y_in,
const T &width_in,
const T &height_in)
56 p.
x = this->
x + this->
width / 2;
62 this->
x = p.
x - this->
width / 2;
70 ss <<
"[ " <<
width <<
" x " <<
height <<
" ] from ( " <<
x <<
" , " <<
y 77 T r1_xmax = rect1.
x + rect1.
width;
79 T r1_ymax = rect1.
y + rect1.
height;
81 T r2_xmax = rect2.
x + rect2.
width;
83 T r2_ymax = rect2.
y + rect2.
height;
84 if (r2_xmin <= r1_xmax && r2_xmax >= r1_xmin && r2_ymin <= r1_ymax &&
86 T xmin = std::max(r1_xmin, r2_xmin);
87 T ymin = std::max(r1_ymin, r2_ymin);
88 T xmax = std::min(r1_xmax, r2_xmax);
89 T ymax = std::min(r1_ymax, r2_ymax);
90 return Rect<T>(xmin, ymin, xmax - xmin, ymax - ymin);
98 ret.
x = std::min(rect1.
x, rect2.
x);
99 ret.
y = std::min(rect1.
y, rect2.
y);
114 return !(rect1 == rect2);
123 template <
typename T>
125 BBox2D() : xmin(0), ymin(0), xmax(0), ymax(0) {}
127 BBox2D(
const T &xmin_in,
const T &ymin_in,
const T &xmax_in,
const T &ymax_in)
128 : xmin(xmin_in), ymin(ymin_in), xmax(xmax_in), ymax(ymax_in) {}
133 this->xmax = rect.
x + rect.
width;
134 this->ymax = rect.
y + rect.
height;
140 this->xmax = rect.
x + rect.
width;
141 this->ymax = rect.
y + rect.
height;
147 p.
x = this->xmin + (this->xmax - this->xmin) / 2;
148 p.
y = this->ymin + (this->ymax - this->ymin) / 2;
152 T
Area()
const {
return (xmax - xmin) * (ymax - ymin); }
T ymin
Definition: box.h:154
std::enable_if< std::is_integral< T >::value, bool >::type Equal(const T &lhs, const T &rhs)
Definition: comparison_traits.h:28
Point2D< T > Center() const
Definition: box.h:54
T width
Definition: box.h:119
Rect()
Definition: box.h:34
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
BBox2D< float > BBox2DF
Definition: box.h:164
BBox2D()
Definition: box.h:125
void SetCenter(Point2D< T > p)
Definition: box.h:61
std::string ToStr() const
Definition: box.h:68
BBox2D(const Rect< T > &rect)
Definition: box.h:130
T Area() const
Definition: box.h:152
Rect< double > RectD
Definition: box.h:161
Rect(const T &x_in, const T &y_in, const T &width_in, const T &height_in)
Definition: box.h:36
T x
Definition: point.h:83
T y
Definition: point.h:84
BBox2D< double > BBox2DD
Definition: box.h:165
BBox2D< T > & operator=(const Rect< T > &rect)
Definition: box.h:137
friend Rect< T > operator|(const Rect< T > &rect1, const Rect< T > &rect2)
Definition: box.h:96
Point2D< T > Center() const
Definition: box.h:145
BBox2D< int > BBox2DI
Definition: box.h:163
T ymax
Definition: box.h:156
T height
Definition: box.h:120
T xmin
Definition: box.h:153
friend Rect< T > operator &(const Rect< T > &rect1, const Rect< T > &rect2)
Definition: box.h:75
T xmax
Definition: box.h:155
Rect< float > RectF
Definition: box.h:160
friend bool operator==(const Rect &rect1, const Rect &rect2)
Definition: box.h:107
Rect< int > RectI
Definition: box.h:159
friend bool operator!=(const Rect &rect1, const Rect &rect2)
Definition: box.h:113
Rect< T > & operator=(const BBox2D< T > &bbox)
Definition: box.h:46
Rect(const BBox2D< T > &bbox)
Definition: box.h:39
T Area() const
Definition: box.h:66
BBox2D(const T &xmin_in, const T &ymin_in, const T &xmax_in, const T &ymax_in)
Definition: box.h:127