0
Ich muss n
Punkte innerhalb von N-Gon gleichmäßig verteilt generieren. Zusätzlich möchte ich in Matrix nx2
speichern.Zufallszahl innerhalb regelmäßigen Polygon
Ich muss n
Punkte innerhalb von N-Gon gleichmäßig verteilt generieren. Zusätzlich möchte ich in Matrix nx2
speichern.Zufallszahl innerhalb regelmäßigen Polygon
Sie können spsample
in sp
Paket verwenden:
library(sp)
pol <- matrix(c(0 ,0 ,2 ,0 ,2 ,2 ,0 , 2, 0, 0), byrow = T, ncol = 2)
pol <- Polygon(pol)
spsample(pol, 100, type = "random")
Beispiel:
pol <- matrix(c(5 ,1.5 ,1 ,8 ,3 ,12 ,8 , 10, 14, 5), byrow = T, ncol = 2)
pol <- Polygon(pol)
s <- spsample(pol, 1000, type = "random")
[email protected] %>% as.data.frame() %>% set_names(c("x", "y")) %>%
ggplot(aes(x, y)) + geom_polygon(color = "black") +
geom_point(data = [email protected] %>% data.frame() %>% set_names(c("x", "y")), colour = "white")
Bitte fügen Sie, was Sie bereits versucht haben. http://stackoverflow.com/help/how-to-ask –