Skip to contents

[Experimental]

Rotates coordinates in Cartesian space based on two alignment points. The rotation aligns these points either with the 0-degree axis (parallel) or makes them perpendicular to it. This is particularly useful for creating egocentric reference frames or standardizing orientation across multiple frames or individuals.

Usage

rotate_coords(data, alignment_points, align_perpendicular = FALSE)

Arguments

data

movement data frame with columns: time, individual, keypoint, x, y

alignment_points

character vector of length 2 specifying the keypoint names to use for alignment

align_perpendicular

logical; if TRUE, alignment_points will be rotated to be perpendicular to the 0-degree axis. If FALSE (default), alignment_points will be rotated to align with the 0-degree axis

Value

movement data frame with rotated coordinates

Details

The function processes each individual separately and maintains their independence. For each time point, it:

  1. Calculates the vector between the alignment points

  2. Determines the current angle of this vector

  3. Rotates all points to achieve the desired alignment