View source: R/is_convex_hull.R
is_convex_hull | R Documentation |
Test if a given set of vertices construct a convex hull.
is_convex_hull(x)
x |
|
polygon
convex_hull
is_anticlockwise
xvert <- c(0, 5, 6, 4, 2, 0)
yvert <- c(0, 0, 1, 3, 3, 2)
pg <- polygon(xvert, yvert)
is_convex_hull(pg)
# reverse the order of the vertices, still an convex hull.
is_convex_hull(polygon(pg$vertices[rev(1:nrow(pg$vertices)), ] ))
# order of the vertices is important
is_convex_hull(polygon(pg$vertices[c(2, 3, 1, 6, 4, 5), ] ))
star <-
rbind(sccm::polar2cartesian(r = 1.0, theta = seq(0, 1.6, by = 0.4) * pi),
sccm::polar2cartesian(r = 0.6, theta = seq(0.2, 1.8, by = 0.4) * pi))
is_convex_hull(polygon(star))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.