Created
March 26, 2020 09:23
-
-
Save vankesteren/0b3aa2cff94f72dd6d78b1c3c8241f5e to your computer and use it in GitHub Desktop.
Delaunay triangulation and voronoi tesselation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(deldir) | |
library(ggplot2) | |
library(firatheme) | |
N <- 40 | |
dat <- matrix(rnorm(N*2), N) | |
dat <- dat %*% chol(matrix(c(1, 0, 0, 1.5), 2)) %*% chol(solve(cov(dat))) | |
dat2 <- deldir(dat[,1], dat[,2]) | |
dat1 <- data.frame(dat) | |
colnames(dat1) <- c("x1", "y1") | |
ggplot(dat2$delsgs, aes(x = x1, y = y1)) + | |
geom_segment(aes(xend = x2, yend = y2),size = 0.5, colour = "#99DA99") + | |
geom_point(data = dat1, colour = "#9999DA") + | |
geom_segment(aes(xend = x2, yend = y2), data = dat2$dirsgs, colour = "#DA9999") + | |
theme_void() + | |
coord_fixed() |
Author
vankesteren
commented
Mar 26, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment