I have a a
list with three arrays and a v
vector with three frequencies (any positive real ones), these arrays form triangles through a function that created pplot
. I want to add the information of v
to build prisms, that is, exit from 2D to 3D. Does anyone have any ideas or tips on how to do it?
Below is the function pplot
and a toy problem:
library(ggplot2)
pplot <- function(polygon){
polygon <- lapply(polygon, function(x) {colnames(x) <- NULL; x})
vertex_number = nrow(polygon[[1]])
g = ggplot2::ggplot()
names(polygon) = 1:length(polygon)
k <- plyr::ldply(polygon, function(x) data.frame(x))
g <- ggplot2::ggplot(k, ggplot2::aes(x = X1, y = X2, group = .id)) + ggplot2::geom_polygon(colour = "black", fill = NA)
return(g)
}
a <- list()
b1 <- matrix(rnorm(6), ncol = 2)
b2 <- matrix(rnorm(6), ncol = 2)
b3 <- matrix(rnorm(6), ncol = 2)
a[[1]] <- b1
a[[2]] <- b2
a[[3]] <- b3
v <- c(.3, .5, .1)
#Para exemplificar a funcao que eh 2D
pplot(a)
Note: The data is mandatory.
Desired response
For example, by forming a prism through b1
and v[1]
, then the prism base is b1
and height (h) is v[1]
. The same reasoning goes on b2
with v[2]
and b3
with v[3]
.