Asignacion: Hacer las teselas a partir de los puntos interiores al poligono (convex hull)
library(readxl)
BD_MODELADO <- read_excel("BD_MODELADO.xlsx")
dforiginal <- data.frame(BD_MODELADO)
df <- data.frame(BD_MODELADO) #datos modificados
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)
Teselación Voroni
library(deldir)
## deldir 0.2-3 Nickname: "Stack Smashing Detected"
##
## Note 1: As of version 0.2-1, error handling in this
## package was amended to conform to the usual R protocol.
## The deldir() function now actually throws an error
## when one occurs, rather than displaying an error number
## and returning a NULL.
##
## Note 2: As of version 0.1-29 the arguments "col"
## and "lty" of plot.deldir() had their names changed to
## "cmpnt_col" and "cmpnt_lty" respectively basically
## to allow "col" and and "lty" to be passed as "..."
## arguments.
##
## Note 3: As of version 0.1-29 the "plotit" argument
## of deldir() was changed to (simply) "plot".
##
## See the help for deldir() and plot.deldir().
t<-deldir(df$Avg_X_MCB,df$Avg_Y_MCE,sort=T,plotit = T,digits = 4)
l<-tile.list(t)
plot(t)
length(t$summary$del.area)
## [1] 313
sum(t$summary$del.area)
## [1] 0
Teselación Convex Hull GrÔfica teselas
library(geometry)
xy <- matrix(data = c(df$Avg_X_MCB, df$Avg_Y_MCE), ncol = 2)
tch <- delaunayn(xy)
trimesh(tch,xy)
Areas de teselas Function delaunayn: āThe Delaunay triangulation is a tessellation of the convex hull of the points such that no N-sphere defined by the N- triangles contains any other points from the set.ā Me esta entregado el area de los poligonos formados por la unión de las coordenadas
tch1 <- delaunayn(xy, output.options = "Fa")
hist(tch1$areas)
sum(tch1$areas)
## [1] 3.275718e-07
library(alphahull)
chull <- ahull(xy, alpha = 0.2)
# Plot including the alpha-convex hull in pink, alpha-shape in blue,
# sample points in black, voronoi diagram in green
# and Delaunay triangulation in red
plot(chull, do.shape = TRUE, wlines = "both", col = c(6, 4, 1, 2, 3))
Datos modificados
library(alphahull)
chull <- ahull(xy, alpha = 0.2)
# Plot including the alpha-convex hull in pink, alpha-shape in blue,
# sample points in black, voronoi diagram in green
# and Delaunay triangulation in red
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
# alpha-convex hull
ahull.obj <- ahull(x, alpha = alpha)
# Plot including the alpha-convex hull in pink, alpha-shape in blue,
# sample points in black, voronoi diagram in green
# and Delaunay triangulation in red
plot(ahull.obj, do.shape = TRUE, wlines = "both", col = c(6, 4, 1, 2, 3))