Traj3DSpeed: Speed along a 3-dimensional trajectory

View source: R/3D.R

Traj3DSpeedR Documentation

Speed along a 3-dimensional trajectory

Description

Speed is calculated as the magnitude of velocity. The returned speed will contain leading and/or trailing 'NA' values, depending on the type of differences used to calculate velocity.

Usage

Traj3DSpeed(vel)

Arguments

vel

Velocity of a 3-dimensional trajectory, as returned by Traj3DVelocity.

Details

If the trajectory has constant time steps, then the average speed of the trajectory is 'mean(Traj3DSpeed(Traj3DVelocity(trj)), na.rm = TRUE)'. A trajectory can be resampled by Traj3DResampleTime so that it has constant time steps.

This function is implemented to simply interpret each row of a matrix as a 3D vector, and return their lengths. Accordingly, this function can also be used to calculate the magnitude of acceleration as returned by Traj3DAcceleration.

Value

Numeric vector with speed at each point along the trajectory.

See Also

Traj3DVelocity to calculate the 3D velocity, Traj3DAcceleration to calculate the 3D acceleration, Traj3DLength, TrajDuration, Traj3DResampleTime

Examples

## Not run: 
# Get the velocity along the trajectory
speed <- Traj3DSpeed(Traj3DVelocity(trj3d))

# Alternative method to calculate mean speed of a portion of a trajectory
si <- 10
ei <- 400
# Mean speed is displacement divided by time
speedMean <- Traj3DLength(trj3d, startIndex = si, endIndex = ei) /
                TrajDuration(trj3d, startIndex = si, endIndex = ei)

## End(Not run)


JimMcL/trajr documentation built on Jan. 31, 2024, 12:57 a.m.