coo_sample: Sample shapes

Description Usage Arguments Details Value Functions See Also Examples

View source: R/coo_modifyers.R

Description

Changes the number of shape coordinates.

Usage

1
2
3
4
5
coo_sample(x, n, from_col, to_col, ...)

coo_sample_prop(x, prop, from_col = coo, to_col = coo, ...)

coo_interpolate(x, n, from_col, to_col, ...)

Arguments

x

coo_single, coo_list or mom_tbl

n

integer desired number of coordinates (required)

from_col

colnames from where to get the coo_list and how to name the resulting one (only for mom_tbl method)

to_col

colnames from where to get the coo_list and how to name the resulting one (only for mom_tbl method)

...

useless here

prop

numeric desired poportion of sampled coordinates (required). Below 1 will sample, above 1 will interpolate.

Details

coo_sample will return coordinates regularly sampled along the curvilinear abscissa. The last point will be dropped so that the distance (new last - first) roughly equals all other distances between consecutive points. This is typically useful for outlines. coo_sample_curve (todo link) will preserve the first and last points. This is typically useful for curves, hence the name. coo_interpolate will upsample the number of points. All functions have a _prop ally, where n is deduced from the proportion you want to retain.

Value

a coo_single, coo_list or mom_tbl

Functions

See Also

Other coo_modifyers: coo_align(), coo_baseline(), coo_center(), coo_reflect, coo_rev(), coo_rotatecenter(), coo_rotate(), coo_sample_rr(), coo_scale(), coo_shear(), coo_slide(), coo_split(), coo_template(), coo_trans(), coo_trim(), coo_up()

Examples

1
2
3
4
5
6
x <- bot %>% pick(1) %>% coo_sample(24)
x %>% gg()
x %>% coo_interpolate(120) %>% gg()

bot$coo[1:2] %>% coo_sample(12) %>% purrr::map_dbl(nrow)
bot$coo[1:2] %>% coo_sample(12) %>% coo_interpolate(24) %>% purrr::map_dbl(nrow)

MomX/Momocs2 documentation built on May 13, 2020, 4:28 a.m.