Rutils/maybe-not-useful/accum.dist.r

#==========================================================================================#
#==========================================================================================#
#      This function accumulates the distance along a path.                                #
#----------------------------------------------------------~-------------------------------#
accum.dist <<- function(x,y=NULL){
   #----- Find out whether x and y were given or if they are both in x. -------------------#
   if (is.null(y)){
      y = x$y
      x = x$x
   }#end if
   #---------------------------------------------------------------------------------------#


   #----- Find the distance between two consecutive points, then add them up. -------------#
   dx   = diff(x)
   dy   = diff(y)
   dist = cumsum(c(0,sqrt(dx*dx+dy*dy)))
   return(dist)
   #---------------------------------------------------------------------------------------#
}#end accum.dist
#==========================================================================================#
#==========================================================================================#
manfredo89/ED2io documentation built on May 21, 2019, 11:24 a.m.