-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
133 additions
and
6 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
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
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
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,28 @@ | ||
#' Resample a trajectory to a constant time interval. | ||
#' | ||
#' Constructs a new trajectory by resampling the input trajectory to a fixed | ||
#' time interval. Points are linearly interpolated along the trajectory. Spatial | ||
#' and time units are preserved. | ||
#' | ||
#' @param trj The trajectory to be resampled. | ||
#' @param stepTime New sampled step time. Each step in the new trajectory will | ||
#' have this duration. | ||
#' @param newFps Value to be stored as the FPS value in the new trajectory (see | ||
#' \code{\link{TrajGetFPS}}). It is not otherwise used by this function. | ||
#' @return A new trajectory with a constant time interval for each step. Points | ||
#' in the new trajectory are calculated by linearly interpolating along | ||
#' \code{trj}. | ||
#' | ||
#' @export | ||
TrajResampleTime <- function(trj, stepTime, newFps = NULL) { | ||
# Determine times of new points | ||
times <- seq(from = min(trj$time), to = max(trj$time), by = stepTime) | ||
# Interpolate x and y separately | ||
x <- stats::approx(trj$time, trj$x, times)$y | ||
y <- stats::approx(trj$time, trj$y, times)$y | ||
|
||
TrajFromCoords(data.frame(x, y, times), timeCol = 3, | ||
fps = newFps, | ||
spatialUnits = TrajGetUnits(trj), | ||
timeUnits = TrajGetTimeUnits(trj)) | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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