R/trackSpeed.R

Defines functions trackSpeed

Documented in trackSpeed

trackSpeed <- function(coords, time) {
    dt <- diff(as.numeric(time))
    d2 <- diff(as.matrix(coords))^2
    speed <- d2[,1]
    ndim <- ncol(d2)
    if(ndim > 1)
      speed <- d2 %*% rep(1,ndim)
    else
      speed <- d2
    sqrt(as.vector(speed))/dt
}
    

Try the SoDA package in your browser

Any scripts or data that you put into this service are public.

SoDA documentation built on Oct. 28, 2020, 9:07 a.m.