Skip to contents

Intended for the use in custom step functions.

Usage

extrapolate_moment(moment, timestep, cur_time, new_time = NULL)

Arguments

moment

Position tibble with extra columns `direction` and `speed`

timestep

How far into future should the objects move (linearly)

cur_time

Current time, for time-sensitive speed functions (e.g., accelerations)

new_time

New time value for the returned object. If omitted, it is calculated automatically as `cur_time + timestep`

Value

Another moment - position tibble with extra columns `direction` and `speed` corresponding to time_next

Examples

moment <- position8c %>% add_random_direction() %>%
  dplyr::mutate(speed = 3)
extrapolate_moment(moment, 0.1, 0)
#> # A tibble: 8 × 6
#>   object      x      y direction speed  time
#>    <int>  <dbl>  <dbl>     <dbl> <dbl> <dbl>
#> 1      1 -0.913 -1.78      0.178     3   0.1
#> 2      2 -3.47  -0.335     0.493     3   0.1
#> 3      3 -3.06   5.22      0.787     3   0.1
#> 4      4 -6.26  -1.09      5.06      3   0.1
#> 5      5  4.07  -5.57      4.31      3   0.1
#> 6      6  0.734 -4.38      4.30      3   0.1
#> 7      7 -5.24   3.25      4.64      3   0.1
#> 8      8  5.78  -1.59      0.584     3   0.1