commit 779c47c556c3f771b1a18dc9e6500d90e3b6ebb6
parent 9b418fd90481cdeb595aa0c5f811238aee7eaa9e
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date: Thu, 22 Sep 2016 13:52:13 -0400
Incorporating new flighttrajectory stuff to identify*Changes()
Diffstat:
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/R/identifyManeuvers.R b/R/identifyManeuvers.R
@@ -12,16 +12,11 @@
#'
#' @export
identifyBearingChanges <- function(trajectory, hiThresh) {
- bearings <- coordsToBearing(trajectory)
+ bearings <- as.flighttrajectory(trajectory)$bearing
- bearings[length(bearings)] <- bearings[length(bearings)-1]
- bearingChanges <- c(diff(bearings), NA)
-
- # Keep bearingChanges in the range [-180, 180]
- bearingChanges[!is.na(bearingChanges) & bearingChanges < -180] <-
- bearingChanges[!is.na(bearingChanges) & bearingChanges < -180] + 360
- bearingChanges[!is.na(bearingChanges) & bearingChanges > 180] <-
- bearingChanges[!is.na(bearingChanges) & bearingChanges > 180] - 360
+ bearingChanges <- c(angleDiff(bearings[1:(length(bearings)-1)],
+ bearings[2:length(bearings)]),
+ NA)
isBearingChange <- abs(bearingChanges) > hiThresh
@@ -42,7 +37,7 @@ identifyBearingChanges <- function(trajectory, hiThresh) {
#'
#' @export
identifyAltitudeChanges <- function(trajectory, hiThresh) {
- trajectoryCoords <- get3dCoords(trajectory)
+ trajectoryCoords <- get3dCoords(as.flighttrajectory(trajectory))
altitudeChanges <- c(diff(trajectoryCoords[, 3]), 0)
isAltitudeChange <- abs(altitudeChanges) > hiThresh