Realizar teselas a partir de os puntos interiores al poligono (convex hull)
library(readxl)
library(deldir)
## deldir 0.1-29
##
## Please note that the arguments "col" and
## "lty" of plot.deldir() have had their
## names changed to "cmpnt_col" and "cmpnt_lty"
## respectively, basically to allow "col" and
## and "lty" to be passed as "..." arguments.
## Also the "plotit" argument of deldir() has
## been changed to (simply) "plot".
## See the help for plot.deldir() and deldir().
library(geometry)
library(alphahull)
BD_MODELADO <-read_excel("C:\\Users\\yarvis\\Music\\Modelos\\BD_MODELADO.xlsx")
dforiginal <- data.frame(BD_MODELADO)
df<-data.frame(BD_MODELADO)
df$Avg_X_MCB<-(df$Avg_X_MCB/mean(df$Avg_X_MCB))-0.2
df$Avg_Y_MCE<-(df$Avg_Y_MCE/mean(df$Avg_Y_MCE))-0.2
xy <- matrix(data=c(df$Avg_X_MCB,df$Avg_Y_MCE), ncol=2)
Coordenadas
plot(df$Avg_X_MCB,df$Avg_Y_MCE,pch=19,cex=1)
Teselacion Voronoi
t<- deldir(df$Avg_X_MCB,df$Avg_Y_MCE, sort=T, plotit = T,digits = 4)
##
## PLEASE NOTE: The components "delsgs" and "summary" of the
## object returned by deldir() are now DATA FRAMES rather than
## matrices (as they were prior to release 0.0-18).
## See help("deldir").
##
## PLEASE NOTE: The process that deldir() uses for determining
## duplicated points has changed from that used in version
## 0.0-9 of this package (and previously). See help("deldir").
l<- tile.list(t)
plot(t)
length(t$summary$del.area)
## [1] 313
sum(t$summary$del.area)
## [1] 0
Teselacion Convex Hull Grafica teselas
xy <- matrix(data = c(df$Avg_X_MCB,df$Avg_Y_MCE), ncol = 2)
tch <- delaunayn(xy)
trimesh(tch,xy)
tch1 <- delaunayn(xy, output.options = "Fa")
hist(tch1$areas)
sum(tch1$areas)
## [1] 3.275718e-07
chull <- ahull(xy, alpha = 0.2)
plot(chull, do.shape = TRUE, wlines = "both", col = c(6,4,1,2,3))
Datos modificados
chull <- ahull(xy, alpha = 0.2)
plot(chull, do.shape = TRUE, wlines = "both",
col= c(6,4,1,2,3))
x <- matrix(runif(100), nc = 2)
# Value of alpha
alpha <- 0.2
ahull.obj <- ahull(x, alpha = alpha)
plot(ahull.obj, do.shape = TRUE, wlines = "both", col = c(6, 4, 1, 2, 3))