library(gyro)
library(uniformly)
set.seed(666)
points <- runif_in_sphere(35L, d = 2)
hdel <- hdelaunay(points, model = "M")
plotHdelaunay(hdel)
points <- runif_in_sphere(35L, d = 2, r = 0.7)
hdel <- hdelaunay(points, model = "U")
plotHdelaunay(hdel)
# example with colors given by a function ####
library(gyro)
if(require("trekcolors")) {
pal <- trek_pal("klingon")
} else {
pal <- hcl.colors(32L, palette = "Rocket")
}
phi <- (1 + sqrt(5)) / 2
theta <- head(seq(0, pi/2, length.out = 11), -1L)
a <- phi^((2*theta/pi)^0.8 - 1)
u <- a * cos(theta)
v <- a * sin(theta)
x <- c(0, u, -v, -u, v)
y <- c(0, v, u, -v, -u)
pts <- cbind(x, y) / 1.03
hdel <- hdelaunay(pts, model = "M")
fcolor <- function(t){
RGB <- colorRamp(pal)(t)
rgb(RGB[, 1L], RGB[, 2L], RGB[, 3L], maxColorValue = 255)
}
plotHdelaunay(
hdel, vertices = FALSE, circle = FALSE, color = fcolor
)
Run the code above in your browser using DataLab