Skip to contents

Pressure-weighted centroid of each frame expressed in grid indices: a cop_row of 1 is the first sensor row, a cop_col of 16 the sixteenth sensor column. Row and col are read from the layout's coordinate table positionally, so the result stays correct under any device channel permutation applied by the reader.

Usage

pr_calc_cop_grid(trial, threshold = 0, eps = 1e-12)

Arguments

trial

A pr_trial object.

threshold

Numeric. Cells at or below this value count as unloaded. Default 0.

eps

Numeric. Added to the weight sum to keep unloaded frames finite. Default 1e-12.

Value

A tibble::tibble with one row per frame and columns frame (integer), time_s, cop_row, cop_col (grid index units).

Details

pr_calc_cop() returns the same centroid in millimetres and gives NA for frames with no load. This function is the index-unit counterpart used when a device's physical sensor pitch was never published, so millimetre coordinates would be fabricated. Instead of NA, an unloaded frame gets a centroid of approximately 0 for both axes: eps is added to the weight sum, so the quotient is 0 / eps rather than 0 / 0. That keeps the output a complete, non-NA time series, and cop_row == 0 is unambiguous because a real centroid is always at least 1.

Note also that the whole-grid metrics here differ from pr_calc_mean_pressure(), which is loaded-cells-only by definition.

Examples

trial <- pr_example_trial("saddle_horse")
cop <- pr_calc_cop_grid(trial)
range(cop$cop_row)
#> [1] 8.220827 8.769230