diff --git a/R/kdtree.R b/R/kdtree.R index 5d202b8..5f990a2 100644 --- a/R/kdtree.R +++ b/R/kdtree.R @@ -160,7 +160,7 @@ interp_tris <- function(query_coordinates, mesh_vertices, nearest_face_vertices, interp_tris_cpp_wrapper <- function(query_coordinates, mesh_vertices, nearest_face_vertices, pervertex_data, iwd_beta = 2.0) { # adjust indexing for C++ - nearest_face_vertices = nearest_face_vertices + 1L; + #nearest_face_vertices = nearest_face_vertices + 1L; return(.Call("interp_tris_c", query_coordinates, mesh_vertices, nearest_face_vertices, pervertex_data, iwd_beta)); } diff --git a/tests/testthat/test_kdtree.R b/tests/testthat/test_kdtree.R index a0de9ed..31ca690 100644 --- a/tests/testthat/test_kdtree.R +++ b/tests/testthat/test_kdtree.R @@ -98,6 +98,14 @@ testthat::test_that("The R and CPP versions of the linear_interpolate_kdtree fun testthat::expect_true(is.double(dest_pervertex_data_CPP)); testthat::expect_equal(length(dest_pervertex_data_CPP), nrow(dest_mesh$vertices)); + # The min values should be zero for both. + testthat::expect_equal(min(dest_pervertex_data_R), 0.0); + testthat::expect_equal(min(dest_pervertex_data_CPP), 0.0); + + # The max values are not identical for some reason (precision?), but should be in same range. + testthat::expect_true(max(dest_pervertex_data_R) > 4.6 & max(dest_pervertex_data_R) < 4.8); + testthat::expect_true(max(dest_pervertex_data_CPP) > 4.6 & max(dest_pervertex_data_CPP) < 4.8); + # The real test for similar values: testthat::expect_equal(dest_pervertex_data_R, dest_pervertex_data_CPP, tolerance=1e-1);