Skip to contents

Computes the main swimming axis of a midline as a unit vector, using the singular value decomposition (svd()). This only works well if the midlines are centered around zero, so it optionally subtracts off the mean of x and y. For more sophisticated centering algorithms, see get_midline_center_df().

Usage

get_primary_swimming_axis(x, y, center = TRUE)

Arguments

x, y

Coordinates of the midline

center

(TRUE or FALSE) Subtract the mean from the x and y coordinates

Value

A data frame with the following columns:

  • swimaxis_x, swimaxis_y x and y components of the swimming axis vector

  • swimaxis_xctr, swimaxis_yctr Mean x and y values that were subtracted before running the SVD

Examples

# run the algorithm across multiple midlines at different times
lampreydata |>
  group_by(t) |>
  summarize(swimaxis = get_primary_swimming_axis(mxmm, mymm)) |>
  unnest(swimaxis)
#> Error in unnest(summarize(group_by(lampreydata, t), swimaxis = get_primary_swimming_axis(mxmm,     mymm)), swimaxis): could not find function "unnest"