distanceTraveled: Calculates the total distance traveled through a series of...

View source: R/distanceTraveled.R

distanceTraveledR Documentation

Calculates the total distance traveled through a series of points.

Description

Computes the cumulative distance between consecutive points in a given set of coordinates. It sums the Euclidean distances between each pair of adjacent points, providing the total distance traveled along the path defined by the points.

Usage

distanceTraveled(points)

Arguments

points

A matrix or data frame where each row represents a point with its coordinates (e.g., x and y).

Value

A numeric value representing the total distance traveled through the points.

Examples

# Define a set of points
points <- matrix(c(0, 0, 1, 1, 2, 0), ncol = 2, byrow = TRUE)
# Calculate the distance traveled
total_distance <- distanceTraveled(points)
# Print the total distance
print(total_distance)


BioTrajectory documentation built on June 8, 2025, 11:54 a.m.