57 unsigned int g_min_x, g_min_y, g_max_x, g_max_y;
65 double min_x, min_y, max_x, max_y;
72 unsigned int n_cols,
unsigned int n_rows)
74 if (n_cols * n_rows == 0)
76 throw std::invalid_argument(
"Number of rows and columns must be positive (not zero)");
78 unsigned int full_width = original_bounds.
getWidth(),
79 full_height = original_bounds.
getHeight();
81 unsigned int small_width =
static_cast<unsigned int>(ceil(static_cast<double>(full_width) / n_cols)),
82 small_height = static_cast<unsigned int>(ceil(static_cast<double>(full_height) / n_rows));
84 std::vector<nav_core2::UIntBounds> divided;
86 for (
unsigned int row = 0; row < n_rows; row++)
88 unsigned int min_y = original_bounds.
getMinY() + small_height * row;
89 unsigned int max_y = std::min(min_y + small_height - 1, original_bounds.
getMaxY());
91 for (
unsigned int col = 0; col < n_cols; col++)
93 unsigned int min_x = original_bounds.
getMinX() + small_width * col;
94 unsigned int max_x = std::min(min_x + small_width - 1, original_bounds.
getMaxX());
97 divided.push_back(sub);
NumericType getMaxX() const
A set of utility functions for Bounds objects interacting with other messages/types.
NumericType getMinX() const
NumericType getMinY() const
std::vector< nav_core2::UIntBounds > divideBounds(const nav_core2::UIntBounds &original_bounds, unsigned int n_cols, unsigned int n_rows)
divide the given bounds up into sub-bounds of roughly equal size
void gridToWorld(const NavGridInfo &info, int mx, int my, double &wx, double &wy)
GenericBounds< double > Bounds
nav_core2::UIntBounds translateBounds(const nav_grid::NavGridInfo &info, const nav_core2::Bounds &bounds)
Translate real-valued bounds to uint coordinates based on nav_grid info.
unsigned int getHeight() const
nav_core2::UIntBounds getFullUIntBounds(const nav_grid::NavGridInfo &info)
return an integral bounds that covers the entire NavGrid
nav_core2::Bounds getFullBounds(const nav_grid::NavGridInfo &info)
return a floating point bounds that covers the entire NavGrid
unsigned int getWidth() const
NumericType getMaxY() const
bool worldToGridBounded(const NavGridInfo &info, double wx, double wy, unsigned int &mx, unsigned int &my)