TrajSmoothSG: Smooth a trajectory using a Savitzky-Golay filter

View source: R/trajectory.R

TrajSmoothSGR Documentation

Smooth a trajectory using a Savitzky-Golay filter

Description

Smooths a trajectory using a Savitzky-Golay smoothing filter.

Usage

TrajSmoothSG(trj, p = 3, n = p + 3 - p%%2, ...)

Arguments

trj

The trajectory to be smoothed.

p

polynomial order (passed to sgolayfilt).

n

Filter length (or window size), must be an odd number. Passed to sgolayfilt.

...

Additional arguments are passed to sgolayfilt.

Details

Consider carefully the effects of smoothing a trajectory with temporal gaps in the data. If the smoothed trajectory is used to derive speed and/or acceleration, it may be advisable to fill in the gaps before smoothing, possibly by calling TrajResampleTime.

Value

A new trajectory which is a smoothed version of the input trajectory.

See Also

sgolayfilt

Examples

set.seed(3)
trj <- TrajGenerate(500, random = TRUE, angularErrorSd = .25)
smoothed <- TrajSmoothSG(trj, 3, 31)
plot(trj)
plot(smoothed, col = "red", add = TRUE)


trajr documentation built on May 29, 2024, 11:52 a.m.