35 #ifndef NAV_CORE2_BOUNDS_H 36 #define NAV_CORE2_BOUNDS_H 51 template <
typename NumericType>
52 inline bool inRange(
const NumericType value,
const NumericType min_value,
const NumericType max_value)
54 return min_value <= value && value <= max_value;
61 template <
typename NumericType>
80 GenericBounds(NumericType x0, NumericType y0, NumericType x1, NumericType y1)
88 min_x_ =
min_y_ = std::numeric_limits<NumericType>::max();
89 max_x_ =
max_y_ = std::numeric_limits<NumericType>::lowest();
95 void touch(NumericType x, NumericType y)
110 void update(NumericType x0, NumericType y0, NumericType x1, NumericType y1)
174 return "(" + std::to_string(
min_x_) +
"," + std::to_string(
min_y_) +
"):(" +
175 std::to_string(
max_x_) +
"," + std::to_string(
max_y_) +
")";
179 return "(empty bounds)";
194 inline unsigned int getDimension(
unsigned int min_v,
unsigned int max_v)
196 return (min_v > max_v) ? 0 : max_v - min_v + 1;
209 #endif // NAV_CORE2_BOUNDS_H
GenericBounds(NumericType x0, NumericType y0, NumericType x1, NumericType y1)
Constructor for a non-empty initial bounds.
NumericType getMaxX() const
bool operator!=(const GenericBounds< NumericType > &other) const
bool overlaps(const GenericBounds< NumericType > &other) const
returns true if the two bounds overlap each other
NumericType getMinX() const
GenericBounds()
Constructor for an empty bounds.
NumericType getMinY() const
void reset()
Reset the bounds to be empty.
bool contains(NumericType x, NumericType y) const
Returns true if the point is inside this range.
unsigned int getDimension(unsigned int min_v, unsigned int max_v)
void touch(NumericType x, NumericType y)
Update the bounds to include the point (x, y)
bool operator==(const GenericBounds< NumericType > &other) const
comparison operator that requires all fields are equal
void update(NumericType x0, NumericType y0, NumericType x1, NumericType y1)
Update the bounds to include points (x0, y0) and (x1, y1)
bool isEmpty() const
Returns true if the range is empty.
bool inRange(const NumericType value, const NumericType min_value, const NumericType max_value)
Templatized method for checking if a value falls inside a one-dimensional range.
void merge(const GenericBounds< NumericType > &other)
Update the bounds to include the entirety of another bounds object.
std::string toString() const
Returns a string representation of the bounds.
Templatized class that represents a two dimensional bounds with ranges [min_x, max_x] [min_y...
unsigned int getHeight() const
unsigned int getWidth() const
NumericType getMaxY() const