Learn R Programming

trajr (version 1.5.1)

TrajTranslate: Translate a trajectory

Description

Shifts an entire trajectory by the specified delta x and y.

Usage

TrajTranslate(trj, dx, dy, dt = 0)

Value

A new trajectory which is a translated version of the input trajectory.

Arguments

trj

The Trajectory to be translated.

dx

Delta x.

dy

Delta y.

dt

Delta time.

Examples

Run this code
# Shift a trajectory so that its origin is (10, 15).
# Note that trajectories created by TrajGenerate always start at (0, 0)
set.seed(42)
trj <- TrajGenerate()
trj <- TrajTranslate(trj, 10, 15)

# Translate a trajectory so its origin (0, 0) and it starts at time 0
trj <- TrajTranslate(trj, -trj$x[1], -trj$y[1], -trj$time[1])

Run the code above in your browser using DataLab