DistanceDerivatives.hpp
Go to the documentation of this file.
1 /*
2  * DistanceDerivatives.h
3  *
4  * Created on: Aug 10, 2020
5  * Author: Ruben Grandia
6  * Institute: ETH Zurich
7  */
8 
9 #pragma once
10 
12 
13 namespace grid_map {
14 namespace signed_distance_field {
15 
24 inline void columnwiseCentralDifference(const Matrix& data, Matrix& centralDifference, float resolution) {
25  assert(data.cols() >= 2); // Minimum size to take finite differences.
26 
27  const Eigen::Index m{data.cols()};
28  const float resInv{1.0F / resolution};
29  const float doubleResInv{1.0F / (2.0F * resolution)};
30 
31  // First column
32  centralDifference.col(0) = resInv * (data.col(1) - data.col(0));
33 
34  // All the middle columns
35  for (Eigen::Index i = 1; i + 1 < m; ++i) {
36  centralDifference.col(i) = doubleResInv * (data.col(i + 1) - data.col(i - 1));
37  }
38 
39  // Last column
40  centralDifference.col(m - 1) = resInv * (data.col(m - 1) - data.col(m - 2));
41 }
42 
47 inline void layerFiniteDifference(const Matrix& data_k, const Matrix& data_kp1, Matrix& result, float resolution) {
48  const float resInv{1.0F / resolution};
49  result = resInv * (data_kp1 - data_k);
50 }
51 
56 inline void layerCentralDifference(const Matrix& data_km1, const Matrix& data_kp1, Matrix& result, float resolution) {
57  const float doubleResInv{1.0F / (2.0F * resolution)};
58  result = doubleResInv * (data_kp1 - data_km1);
59 }
60 
61 } // namespace signed_distance_field
62 } // namespace grid_map
Eigen::MatrixXf Matrix
void columnwiseCentralDifference(const Matrix &data, Matrix &centralDifference, float resolution)
void layerCentralDifference(const Matrix &data_km1, const Matrix &data_kp1, Matrix &result, float resolution)
void layerFiniteDifference(const Matrix &data_k, const Matrix &data_kp1, Matrix &result, float resolution)


grid_map_sdf
Author(s): Takahiro Miki , Péter Fankhauser
autogenerated on Wed Jul 5 2023 02:23:42