15 #ifndef NAV2_COSTMAP_2D__DISTANCE_TRANSFORM_HPP_
16 #define NAV2_COSTMAP_2D__DISTANCE_TRANSFORM_HPP_
30 using MatrixXfRM = Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
51 static constexpr
float DT_INF = std::numeric_limits<float>::max();
67 const float * f,
float * d,
int n,
70 if (!f || !d || !v || !z || n <= 0) {
79 for (
int q = 1; q < n; q++) {
82 float s = (f[q] - f[v[k]] +
static_cast<float>(q * q - v[k] * v[k])) /
83 (2.0f *
static_cast<float>(q - v[k]));
86 s = (f[q] - f[v[k]] +
static_cast<float>(q * q - v[k] * v[k])) /
87 (2.0f *
static_cast<float>(q - v[k]));
96 for (
int q = 0; q < n; q++) {
97 while (z[k + 1] <
static_cast<float>(q)) {
100 const int diff = q - v[k];
101 d[q] =
static_cast<float>(diff * diff) + f[v[k]];
124 #pragma omp parallel for schedule(dynamic, 16)
126 for (
int x = 0; x < width; x++) {
128 std::vector<float> f(height);
129 std::vector<float> d(height);
130 std::vector<int> v(height);
131 std::vector<float> z(height + 1);
134 for (
int y = 0; y < height; y++) {
142 for (
int y = 0; y < height; y++) {
149 #pragma omp parallel for schedule(dynamic, 16)
151 for (
int y = 0; y < height; y++) {
153 std::vector<float> f(width);
154 std::vector<float> d(width);
155 std::vector<int> v(width);
156 std::vector<float> z(width + 1);
159 for (
int x = 0; x < width; x++) {
167 for (
int x = 0; x < width; x++) {
173 img = img.cwiseSqrt();
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixXfRM
Row-major float matrix type for efficient row-wise access.