tests/testthat/test-is_convex_hull.R

test_that("is_convex_hull", 
          {
            ch <- convex_hull(mtcars[, c("mpg", "wt")])
            star <- rbind(polar2cartesian(1.0, seq(0, 1.6, by = 0.4) * pi),
                          polar2cartesian(0.5, seq(0.2, 1.8, by = 0.4) * pi)) 
            star <- star[rep(1:5, each = 2) + rep(c(0, 5), times = 5), ]
            star_pg <- polygon(star)
            expect_true(is_convex_hull(ch))
            expect_true(is_convex_hull(polygon(c(-1, -1, 1, 1), c(-1, 1, 1, -1))))  # clockwise square
            expect_true(is_convex_hull(polygon(c(-1, -1, 1, 1), c(1, -1, -1, 1))))  # anti-clockwise square
            expect_false(is_convex_hull(star_pg))
          })
dewittpe/sccm documentation built on Feb. 2, 2024, 5:25 p.m.