animate_global: Animate motioncapture data using global spatial coordinates

View source: R/animation_functions.R

animate_globalR Documentation

Animate motioncapture data using global spatial coordinates

Description

animate_global() animates motioncapture data using global spatial coordinates. Each frame contains a X-Y and Z-Y plot of the captured person. The definitions of X-Y and Z-Y are dictated by the calibration of the system.

Usage

animate_global(
  .data,
  planes = c("X", "Z"),
  planes_in_rows_or_cols = c("cols"),
  row_facets = NULL,
  col_facets = NULL,
  subject = NULL,
  remove_facet_labels = TRUE,
  use_geom_point = TRUE,
  line_colored = TRUE,
  line_colored_size = 1,
  line_colored_alpha = 1,
  line_black = TRUE,
  line_black_size = 1,
  line_black_alpha = 0.5,
  point = TRUE,
  point_size = 2,
  circle_size = 40,
  point_alpha = 1,
  head_scale = 1.5,
  torso_scale = 1.5,
  return_data = FALSE,
  return_plot = FALSE,
  reduce_data = FALSE,
  ...
)

Arguments

.data

A tibble containing joint center positions with global spatial positions of toes, ankles, knees, hip, shoulder, elbows, wrists.

planes

Planes to animate. Must be one or both of c("X", "Z"). The planes are created by combining the suplied direction with the up-direction. Defaults to c("R", "F").

planes_in_rows_or_cols

Facet the chosen planes in either rows or columns. Must be one of c("rows", "cols"). Defaults to "cols".

row_facets

Make additional row-facets in the animation using a given variable. Defaults to NULL.

col_facets

Make additional column-facets in the animation using a given variable. Defaults to NULL.

subject

Column that contains subject ID. Is only needed if more than one subject is present in the same frame.

remove_facet_labels

Remove the facet labels. Defaults to TRUE.

use_geom_point

Defaults to TRUE. If TRUE, points in the animation will be created using ggplot2::geom_point(). If FALSE, points are created using ggforce::geom_circle(). This will ensure correct size-proportions of the points, and that no points are croped out of the animation. However, it comes at the prize of much longer rendering-times.

line_colored

Shall the joints be connected by colored lines? (TRUE or FALSE). Defaults to TRUE.

line_colored_size

The size of the colored lines connecting the joint centers.

line_colored_alpha

The alpha value of the colored lines connecting the joint centers.

line_black

Shall the joints be connected by black lines? (TRUE or FALSE). Defaults to TRUE.

line_black_size

The size of the black lines connecting the joint centers.

line_black_alpha

The alhpa value of the black lines connecting the joint centers.

point

Shall the joint centers be marked by points? (TRUE or FALSE). Defaults to TRUE.

point_size

The size of the joint centers when use_geom_point = TRUE.

circle_size

The size of the joint centers when use_geom_point = FALSE.

point_alpha

The alpha of the points or circles that mark the joint centers.

head_scale

The size of the head relative to the joint-centers.

torso_scale

The size of the torso line relative to the remaing lines.

return_data

Return the wrangled data before it is sent to ggplot. This is useful for understanding the data-structure and for developmental purposes.

return_plot

Return a plot instead of an animaiton. This is useful for customizing the plot before passing it to gganimate::

reduce_data

Defaults to FALSE. If TRUE the function will reduce the input data to only include the variables that are needed for the plot or animation.This may improve performance slightly.

...

Additional arguments are passed to gganimate::animate.

Value

Defaults to an animated gif. Different outputs can be achieved by passing different arguments via ... to the gganimate::animate() function. If return_plot = TRUE a ggplot plot is returned. If return_data = TRUE a tibble is returned.

Examples

df <- dplyr::filter(mocapr::mocapr_data, movement_nr == 1)
df <- dplyr::filter(df, frame %in% c(1, 50, 75, 100))
mocapr::animate_global(df,
                       planes_in_rows_or_cols = "rows",
                       col_facets = frame,
                       return_plot = TRUE)

steenharsted/mocapr documentation built on Feb. 1, 2024, 1:49 p.m.