Applies rotation given by R followed by a translation given by offset in rotated coordinates, to a position coordinate tibble.

reorient_movement(
  df,
  R = diag(3),
  offset = c(0, 0, 0),
  scenario_data = NULL,
  scenario_direction = NA
)

Arguments

df

A movement data frame or positional list with position coordinates in the form _x, _y, _z (uppercase or lowercase)

R

A 3 x 3 rotation matrix (default: no rotation)

offset

A 3-element translation vector rotated coordinates (default: no translation), it can be a positional list too

scenario_data

A scenario object (optional; default: do not use scenario coordinates)

scenario_direction

Either "apply" or "undo"

Value

The same movement tibble with all position columns reoriented in a list, to be used by mutate across rows of a trial_results tibble

Details

This function can also apply or undo the scenario position/rotation given by unity. In Unity, tracker information is stored in GLOBAL coordinates, not in LOCAL scene coordinates. If scenarios were globally translated/rotated, the same physical tracker position would have different global coordinates across trials, or in other words, the tracker data are in different coordinate systems across trials. For "apply", the scenario transformation is applied last, after the user-supplied affine transformation is applied. For "undo", the scenario transformation is undone first, before the user-supplied affine transformation is applied