TrajResampleTime: Resample a trajectory to a constant time interval.

View source: R/resample.R

TrajResampleTimeR Documentation

Resample a trajectory to a constant time interval.

Description

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.

Usage

TrajResampleTime(trj, stepTime, newFps = NULL)

Arguments

trj

The trajectory to be resampled.

stepTime

The resampled trajectory step time. Each step in the new trajectory will have this duration.

newFps

Value to be stored as the FPS value in the new trajectory (see TrajGetFPS). It is not otherwise used by this function.

Details

Resampling with the original step time (i.e., 1/fps) can be used to fill in missing frames in a trajectory.

Value

A new trajectory with a constant time interval for each step. Points in the new trajectory are calculated by linearly interpolating along trj.

Examples

# Simulate a trajectory with steps every 5 hours
set.seed(46)
trj <- TrajGenerate(10, stepLength = 5, fps = 1/5, timeUnits = "hours", linearErrorSd = .8)

# Resample to 1 hour steps
resampled <- TrajResampleTime(trj, 1)

par(mar = c(5, 4, .5, .5))
plot(trj, lwd = 2)
points(trj, pch = 16)
points(resampled, col = "red", draw.start.pt = FALSE)


JimMcL/trajr documentation built on July 23, 2024, 2:06 a.m.