15 #ifndef BELUGA_SENSOR_DATA_LINEAR_GRID_HPP
16 #define BELUGA_SENSOR_DATA_LINEAR_GRID_HPP
63 template <
typename Derived>
71 [[nodiscard]] std::size_t
index_at(
int xi,
int yi)
const {
72 return static_cast<std::size_t
>(yi) * this->
self().width() +
static_cast<std::size_t
>(xi);
79 [[nodiscard]] std::size_t
index_at(
const Eigen::Vector2i& pi)
const {
return this->
self().
index_at(pi.x(), pi.y()); }
90 static_cast<int>(index % this->
self().width()),
static_cast<int>(index / this->
self().width())});
100 [[nodiscard]]
auto data_at(std::size_t index)
const {
101 return index < this->
self().size() ? std::make_optional(this->
self().data()[index]) : std::nullopt;
112 auto result = std::vector<std::size_t>{};
113 const std::size_t xi = index % this->
self().width();
114 const std::size_t yi = index / this->
self().width();
115 if (xi < (this->
self().width() - 1)) {
116 result.push_back(index + 1);
118 if (yi < (this->
self().height() - 1)) {
119 result.push_back(index + this->
self().width());
122 result.push_back(index - 1);
125 result.push_back(index - this->
self().width());