Gets the main swimming axis from a midline
get_primary_swimming_axis.RdComputes 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().
Value
A data frame with the following columns:
swimaxis_x,swimaxis_yx and y components of the swimming axis vectorswimaxis_xctr,swimaxis_yctrMean 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"