Does triangle overlap convex hull of points?
Arguments
- triangles
Three-row matrix as produced by
TriangleCentres().- coordinates
A matrix with two or three rows specifying the coordinates of points in x, y or a, b, c format.
- buffer
Include triangles whose centres lie within
buffertriangles widths (i.e. edge lengths) of the convex hull.
Value
TriangleInHull() returns a list with the elements:
$inside: vector specifying whether each of a set of triangles produced byTriangleCentres()overlaps the convex hull of points specified bycoordinates.$hull: Coordinates of convex hull ofcoordinates, after expansion to cover overlapping triangles.
See also
Other tiling functions:
TriangleCentres()
Examples
set.seed(0)
nPts <- 50
a <- runif(nPts, 0.3, 0.7)
b <- 0.15 + runif(nPts, 0, 0.7 - a)
c <- 1 - a - b
coordinates <- rbind(a, b, c)
TernaryPlot(grid.lines = 5)
TernaryPoints(coordinates, pch = 3, col = 4)
triangles <- TriangleCentres(resolution = 5)
inHull <- TriangleInHull(triangles, coordinates)
polygon(inHull$hull, border = 4)
values <- rbind(triangles,
z = ifelse(inHull$inside, "#33cc3333", "#cc333333"))
points(triangles["x", ], triangles["y", ],
pch = ifelse(triangles["triDown", ], 6, 2),
col = ifelse(inHull$inside, "#33cc33", "#cc3333"))
ColourTernary(values)