Skip to contents

The velocity components (`vx`, `vy`) at each point, aligned to the `Tracks`'s rows. Each point carries the velocity of the step that ends at it (step displacement divided by its elapsed time); the first point of every trajectory is `NA`. The magnitude is [instantaneous_speed()] and the direction is `atan2(vy, vx)`.

Usage

velocity_vector(ts, x_col = ts@cols$x, y_col = ts@cols$y)

Arguments

ts

A `Tracks`.

x_col, y_col

Names of the coordinate columns. Default to the `Tracks`'s recorded x/y columns.

Value

A `data.frame` with columns `vx` and `vy`, one row per observation in `ts@data` order (`NA` at each trajectory's first point).

Details

Numeric (frame) time requires a frame rate ([set_frame_rate()]); POSIXct time is used directly. With a distance calibration ([set_distance_scale()]) the components are in physical units per second; otherwise coordinate units per second.

See also

[instantaneous_speed()], [angular_velocity()], [set_distance_scale()]

Examples

head(velocity_vector(cpunctatus))
#>             vx           vy
#> 1           NA           NA
#> 2  0.001539699  0.001539699
#> 3 -0.001539699  0.000000000
#> 4 -0.001022153  0.000000000
#> 5  0.001022153 -0.004606159
#> 6  0.002050776 -0.003066460