Added bi-linear interpolation for getting Z coordinate at any location in the grid.

This commit is contained in:
2023-05-14 00:03:36 +03:00
parent 91d438353d
commit c05a6a1ad2
6 changed files with 66 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
#include <gtest/gtest.h>
#include "heightmap.h"
TEST(heightmap, get_z_at) {
auto grid = grbl::heightmap::from_params(0, 0, 1, 1, 1);
grid.vertices[0].z = 0;
grid.vertices[1].z = 1;
grid.vertices[2].z = 2;
grid.vertices[3].z = 3;
auto z = grid.get_z_at(0.5f, 0.5f);
EXPECT_EQ(1.5, z);
z = grid.get_z_at(0.5f, 0);
EXPECT_EQ(0.5, z);
z = grid.get_z_at(0.5f, 1);
EXPECT_EQ(2.5, z);
z = grid.get_z_at(0, 0.5f);
EXPECT_EQ(1, z);
z = grid.get_z_at(1, 0.5f);
EXPECT_EQ(2, z);
}