-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for Hausdroff distance computation
- Loading branch information
1 parent
af60c20
commit 61fae65
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
}) |