TrajDAMinMax: First direction autocorrelation minimum/maximum

TrajDAMinMaxR Documentation

First direction autocorrelation minimum/maximum

Description

Determines the coordinates of the first local minimum/maximum of C in the direction autocorrelation function of a trajectory as returned by TrajDirectionAutocorrelations. The end point is excluded from consideration as a minimum, similarly the start point will not be returned as a maximum. If the trajectory does not oscillate in direction, there will not be a local minimum/maximum, and NULL is returned.

Usage

TrajDAFindFirstMinimum(corr, windowSize = 10)

TrajDAFindFirstMaximum(corr, windowSize = 10)

Arguments

corr

A TrajDirectionAutocorrelations object, i.e. the direction autocorrelation of a trajectory.

windowSize

Size of window used to define what constitutes a local mimimum/maximum.

Value

Numeric vector with 2 values, deltaS and C, or NULL if there is no local minimum/maximum.

See Also

TrajDirectionAutocorrelations

Examples

set.seed(42)
trj <- TrajGenerate(600, angularErrorSd = 1)
smoothed <- TrajSmoothSG(trj, 3, 11)

# Resample to fixed path length
resampled <- TrajRediscretize(smoothed, 1)
# Calculate direction autocorrelation for resampled trajectory
corr <- TrajDirectionAutocorrelations(resampled, 100)
# Extract first local minimum from autocorrelation
minPt <- TrajDAFindFirstMinimum(corr, 20)

# Plot the autocorrelation function
plot(corr, type ='l')
# Plot a red dot with a black outline at the first minimum
points(minPt["deltaS"], minPt["C"], pch = 16, col = "red", lwd = 2)
points(minPt["deltaS"], minPt["C"], col = "black", lwd = 2)


JimMcL/trajr documentation built on Jan. 31, 2024, 12:57 a.m.