Skip to content

Commit

Permalink
add test for Hausdroff distance computation
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Aug 26, 2015
1 parent af60c20 commit 61fae65
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/testthat/test_computeAverageHausdorffDistance.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
context("average Hausdorff distance/metric computation")

test_that("computation of average Hausdorff distance yields reasonable results", {
# first we generate two point clouds with large distance
n.points = 20L
pc1 = matrix(runif(n.points * 2L), nrow = 2L)
pc2 = matrix(runif(n.points * 2L), nrow = 2L)

# Now delete one row and expect error
expect_error(computeAverageHausdorffDistance(pc1, pc2[-1L, , drop = FALSE]))

# Now compute the Hausdorff distance repeatedly and increase the distance of the clouds
# The sequence should be increasing.
factors = 2:10
vals = numeric(length(factors) + 1L)
vals[1L] = computeAverageHausdorffDistance(pc1, pc2)
i = 2L
while (i <= length(factors)) {
pc = pc2 * factors[i]
vals[i] = computeAverageHausdorffDistance(pc1, pc)
expect_true(is.numeric(vals[i]), info = sprintf("Hausdorff distance not numeric for factor %i.", factors[i]))
expect_true(vals[i-1] < vals[i], info = sprintf("Hausdorff distance should increase for increasing
distance of the point clouds for factor %i.", factors[i]))
i = i + 1L
}
})

0 comments on commit 61fae65

Please sign in to comment.