regular_grid.hpp
Go to the documentation of this file.
1 // Copyright 2023 Ekumen, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef BELUGA_SENSOR_DATA_REGULAR_GRID_HPP
16 #define BELUGA_SENSOR_DATA_REGULAR_GRID_HPP
17 
18 #include <cmath>
19 
20 #include <ciabatta/ciabatta.hpp>
21 
22 #include <range/v3/view/transform.hpp>
23 
24 #include <Eigen/Core>
26 
32 namespace beluga {
33 
56 
64 template <typename Derived, int NDim>
65 class BaseRegularGrid : public ciabatta::ciabatta_top<Derived> {
66  public:
68 
75  const auto inv_resolution = 1. / this->self().resolution();
76  return (p * inv_resolution).array().floor().template cast<int>();
77  }
78 
80 
87  return (pi.template cast<double>() + Eigen::Vector<double, NDim>::Ones() * 0.5) * this->self().resolution();
88  }
89 
91 
95  template <class Range>
96  [[nodiscard]] auto coordinates_for(Range&& cells) const {
97  return cells | ranges::views::transform([this](const auto& cell) { return this->self().coordinates_at(cell); });
98  }
99 };
101 template <typename Derived>
103 
105 template <typename Derived>
107 
108 } // namespace beluga
109 
110 #endif
eigen_compatibility.hpp
ciabatta.hpp
beluga::BaseRegularGrid::coordinates_at
Eigen::Vector< double, NDim > coordinates_at(const Eigen::Vector< int, NDim > &pi) const
Compute plane coordinates given grid cell coordinates.
Definition: regular_grid.hpp:86
beluga::BaseRegularGrid::coordinates_for
auto coordinates_for(Range &&cells) const
Compute plane coordinates given a range of cell coordinates.
Definition: regular_grid.hpp:96
beluga::BaseRegularGrid::cell_near
Eigen::Vector< int, NDim > cell_near(const Eigen::Vector< double, NDim > &p) const
Compute nearest grid cell coordinates given plane coordinates.
Definition: regular_grid.hpp:74
beluga::BaseRegularGrid
Regularly spaced N dimensional grid base type.
Definition: regular_grid.hpp:65
Eigen::Vector
Eigen::Matrix< Scalar, Dims, 1 > Vector
Type alias for single-column matrices, available starting Eigen 3.4.
Definition: eigen_compatibility.hpp:24
beluga
The main Beluga namespace.
Definition: 3d_embedding.hpp:21


beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53