Learn R Programming

Momocs (version 1.2.9)

coo_intersect_angle: Nearest intersection between a shape and a segment specified with an angle

Description

Take a shape, and segment starting on the centroid and having a particular angle, which point is the nearest where the segment intersects with the shape?

Usage

coo_intersect_angle(coo, angle = 0)

coo_intersect_direction(coo, direction = c("down", "left", "up", "right")[4])

# S3 method for default coo_intersect_direction(coo, direction = c("down", "left", "up", "right")[4])

# S3 method for Coo coo_intersect_direction(coo, direction = c("down", "left", "up", "right")[4])

Arguments

coo

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

angle

numeric an angle in radians (0 by default).

direction

character one of "down", "left", "up", "right" ("right" by default)

Value

numeric the id of the nearest point or a list for Coo See examples.

See Also

Other coo_ intersect: coo_intersect_segment

Examples

Run this code
# NOT RUN {
coo <- bot[1] %>% coo_center %>% coo_scale
coo_plot(coo)
coo %>% coo_intersect_angle(pi/7) %>%
   coo[., , drop=FALSE] %>% points(col="red")

 # many angles
 coo_plot(coo)
 sapply(seq(0, pi, pi/12),
       function(x) coo %>% coo_intersect_angle(x)) -> ids
 coo[ids, ] %>% points(col="blue")

 coo %>%
 coo_intersect_direction("down") %>%
 coo[.,, drop=FALSE] %>% points(col="orange")

# }

Run the code above in your browser using DataLab