Skip to content
Snippets Groups Projects
Commit 7373d16d authored by Karsten Rink's avatar Karsten Rink
Browse files

fixed error in mesh node to raster interpolation

parent b8c022df
No related branches found
No related tags found
No related merge requests found
...@@ -118,14 +118,13 @@ double Raster::interpolateValueAtPoint(MathLib::Point3d const& pnt) const ...@@ -118,14 +118,13 @@ double Raster::interpolateValueAtPoint(MathLib::Point3d const& pnt) const
double const yIdx (std::floor(yPos)); // so not to over- or underflow. double const yIdx (std::floor(yPos)); // so not to over- or underflow.
// weights for bilinear interpolation // weights for bilinear interpolation
double const half_delta = 0.5*_header.cell_size; double const xShift = std::fabs((xPos - xIdx) - 0.5);
double const xShift = std::fabs(xPos-(xIdx+half_delta)) / _header.cell_size; double const yShift = std::fabs((yPos - yIdx) - 0.5);
double const yShift = std::fabs(yPos-(yIdx+half_delta)) / _header.cell_size;
std::array<double,4> weight = {{ (1-xShift)*(1-yShift), xShift*(1-yShift), xShift*yShift, (1-xShift)*yShift }}; std::array<double,4> weight = {{ (1-xShift)*(1-yShift), xShift*(1-yShift), xShift*yShift, (1-xShift)*yShift }};
// neighbors to include in interpolation // neighbors to include in interpolation
int const xShiftIdx = (xPos-xIdx-half_delta>=0) ? 1 : -1; int const xShiftIdx = (xPos - xIdx >= 0.5) ? 1 : -1;
int const yShiftIdx = (yPos-yIdx-half_delta>=0) ? 1 : -1; int const yShiftIdx = (yPos - yIdx >= 0.5) ? 1 : -1;
std::array<int,4> const x_nb = {{ 0, xShiftIdx, xShiftIdx, 0 }}; std::array<int,4> const x_nb = {{ 0, xShiftIdx, xShiftIdx, 0 }};
std::array<int,4> const y_nb = {{ 0, 0, yShiftIdx, yShiftIdx }}; std::array<int,4> const y_nb = {{ 0, 0, yShiftIdx, yShiftIdx }};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment