TrajSpeedIntervals | R Documentation |
Calculates and returns a list of time intervals during which speed is slower
and/or faster than specified values. Speed is calculated by taking the
modulus of velocity (TrajVelocity
).
TrajSpeedIntervals(
trj,
fasterThan = NULL,
slowerThan = NULL,
interpolateTimes = TRUE,
diff = c("backward", "central", "forward")
)
trj |
Trajectory to be analysed. |
fasterThan , slowerThan |
If not |
interpolateTimes |
If |
diff |
Method used to calculate speed, see |
A data frame of class "TrajSpeedIntervals", each row is an interval, columns are:
startFrame |
Indices of frames at the start of each interval. |
stopFrame |
Indices of frames at the end of each interval. |
startTime |
Time since start of trajectory at the start of each interval. |
stopTime |
Time since start of trajectory at the end of each interval |
duration |
Duration of each interval. |
The data frame will also have non-standard attributes:
trajectory |
Value of the |
slowerThan |
Value of the |
fasterThan |
Value of the |
speed |
Data frame with columns |
derivs |
Value returned by calling |
TrajVelocity
for calculating trajectory velocity,
plot.TrajSpeedIntervals
for plotting speed over time with
intervals highlighted.
# Plot speed, highlighting intervals where speed drops below 50 units/sec
set.seed(4)
trj <- TrajGenerate(200, random = TRUE)
smoothed <- TrajSmoothSG(trj, 3, 101)
intervals <- TrajSpeedIntervals(smoothed, diff = "central", slowerThan = 50, fasterThan = NULL)
plot(intervals)
# Report the duration of the longest period of low speed
cat(sprintf("Duration of the longest low-speed interval was %g secs\n", max(intervals$duration)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.