Revision 9e5b9bb8a0564f8bf629df4ca5e96d3078f50363 authored by jmc on 14 July 2008, 00:00:00 UTC, committed by Gabor Csardi on 14 July 2008, 00:00:00 UTC
1 parent a3b36b1
Raw File
trackSpeed.R
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
}
    
back to top