commit 5307b71a54c730d894c25915c801eeea051d3630
parent 1b99e7365545c71831f982916a682f4b4a1356c7
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date: Fri, 20 May 2016 16:47:47 -0400
More tests from appendix, all passing.
Diffstat:
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/tests/testthat/test_calculateSLoWC.R b/tests/testthat/test_calculateSLoWC.R
@@ -5,19 +5,20 @@ library(geosphere)
# I'll attempt to replicate the values in Appendix A of SC-228.
+kacy <- c(-74.5771667, 39.4575833)
+# Traveling at 100 kt for 3 nm.
+ownshipCoords <- destPoint(kacy, 90, seq(0, 5556, length.out = 108))
+intruderCoords <- apply(ownshipCoords, 2, rev)
+ownshipTrajectory <- createTrajectory(ownshipCoords[, 1], ownshipCoords[, 2], 10000)
+
+
test_that("co-altitude head-on examples match", {
- kacy <- c(-74.5771667, 39.4575833)
- # Traveling at 100 kt for 3 nm.
- ownshipCoords <- destPoint(kacy, 90, seq(0, 5556, length.out = 108))
- intruderCoords <- apply(ownshipCoords, 2, rev)
-
- ownshipTrajectory <- createTrajectory(ownshipCoords[, 1], ownshipCoords[, 2])
intruderTrajectory <- list()
hmd <- c(0, 500, 1000, 2000, 3000, 3999, 5000)
for (i in seq_along(hmd)) {
intruderCoordsHMD <- destPoint(intruderCoords, 0, hmd[i]*0.3048)
- intruderTrajectory[[i]] <- createTrajectory(intruderCoordsHMD[, 1], intruderCoordsHMD[, 2])
+ intruderTrajectory[[i]] <- createTrajectory(intruderCoordsHMD[, 1], intruderCoordsHMD[, 2], 10000)
}
# High tolerances to deal with different sampling rates
@@ -29,3 +30,23 @@ test_that("co-altitude head-on examples match", {
expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[6]])), 0.02, tolerance = 5)
expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[7]])), 0)
})
+
+test_that("level head-on with 100' vertical offset examples match", {
+ intruderTrajectory <- list()
+ hmd <- c(0, 500, 1000, 2000, 3000, 3999, 5000)
+ offset <- 100
+
+ for (i in seq_along(hmd)) {
+ intruderCoordsHMD <- destPoint(intruderCoords, 0, hmd[i]*0.3048)
+ intruderTrajectory[[i]] <- createTrajectory(intruderCoordsHMD[, 1], intruderCoordsHMD[, 2], 10000 - offset)
+ }
+
+ # High tolerances to deal with different sampling rates
+ expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[1]])), 77.78, tolerance = 5)
+ expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[2]])), 73.74, tolerance = 5)
+ expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[3]])), 64.39, tolerance = 5)
+ expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[4]])), 41.43, tolerance = 5)
+ expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[5]])), 18.90, tolerance = 5)
+ expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[6]])), 0.02, tolerance = 5)
+ expect_equal(max(calculateSLoWC(ownshipTrajectory, intruderTrajectory[[7]])), 0)
+})