#==========================================================================================#
#==========================================================================================#
# 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
#==========================================================================================#
#==========================================================================================#
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.