Learn R Programming

Momocs (version 1.4.1)

coo_chull: Calculates the (recursive) convex hull of a shape

Description

coo_chull returns the ids of points that define the convex hull of a shape. A simple wrapper around chull, mainly used in graphical functions.

Usage

coo_chull(coo)

# S3 method for default coo_chull(coo)

# S3 method for Coo coo_chull(coo)

coo_chull_onion(coo, close = TRUE)

# S3 method for default coo_chull_onion(coo, close = TRUE)

# S3 method for Coo coo_chull_onion(coo, close = TRUE)

Value

coo_chull returns a matrix of points defining the convex hull of the shape; a list for Coo. coo_chull_onion returns a list of successive onions rings, and a list of lists for Coo.

Arguments

coo

a matrix of (x; y) coordinates or any Coo.

close

logical whether to close onion rings (TRUE by default)

Details

coo_chull_onion recursively find their convex hull, remove them, until less than 3 points are left.

See Also

Other coo_ descriptors: coo_angle_edges(), coo_angle_tangent(), coo_area(), coo_boundingbox(), coo_circularity(), coo_convexity(), coo_eccentricity, coo_elongation(), coo_length(), coo_lw(), coo_rectangularity(), coo_rectilinearity(), coo_scalars(), coo_solidity(), coo_tac(), coo_width()

Examples

Run this code
# coo_chull
h <- coo_sample(hearts[4], 32)
coo_plot(h)
ch <- coo_chull(h)
lines(ch, col='red', lty=2)

bot %>% coo_chull

coo_chull_onion
x <- bot %>% efourier(6) %>% PCA
all_whisky_points <- x %>% as_df() %>% filter(type=="whisky") %>% select(PC1, PC2)
plot(x, ~type, eig=FALSE)
peeling_the_whisky_onion <- all_whisky_points %>% as.matrix %>% coo_chull_onion()
# you may need to par(xpd=NA) to ensure all segments
# even those outside the graphical window are drawn
peeling_the_whisky_onion$coo %>% lapply(coo_draw)
# simulated data
xy <- replicate(2, rnorm(50))
coo_plot(xy, poly=FALSE)
xy %>% coo_chull_onion() %$% coo %>%
lapply(polygon, col="#00000022")

Run the code above in your browser using DataLab