tests/testthat/test-euclidean_distance.R

### Euclidean_distance

test_that("Test whether the euclidean distance estimation works", {

  cartesian <- data.table(X = c(0, 0, 0, 0, 0, 0, 0, 0),
                          Y = c(0, 0, 1, 1, 1, -1, -1, -1),
                          Z = c(0, 10, 0, 5, 10, 0, 5, 10))

  to_test <- round(euclidean_distance(c(0, 0, 5), cartesian), 2)

  distances <- c(5.0, 5.0, 5.1, 1.0, 5.1, 5.1, 1.0, 5.1)

  expect_equal(to_test, distances, info = "Euclidean distance")
})

Try the rTLS package in your browser

Any scripts or data that you put into this service are public.

rTLS documentation built on Dec. 28, 2022, 1:28 a.m.