Copied from email:
Here a fully reproducible example with links grasped by the triangulation of a mesh. This is just an example with nearly non-sense links but sometimes links structure in 3D does not necessarily follow the lines of a triangulation and I think it is always desirable to draw them efficiently.
Maybe you can consider to implement my solution in lineplot()
semielliss<-function (a = 1, b = 1, c = 3, offset = 0.1, parallels = 36,
lands = 36)
{
a <- a
b <- b
c <- c
paralleli <- parallels
landmarks_per_parallelo <- lands
offset <- offset
x <- y <- z <- numeric(0)
for (i in seq(pi/2, offset, length.out = paralleli)) {
num_landmarks <- landmarks_per_parallelo
for (j in seq(2 * pi, offset, length.out = num_landmarks)) {
x <- c(x, a * sin(i) * cos(j))
y <- c(y, b * sin(i) * sin(j))
z <- c(z, c * cos(i))
}
}
x <- c(x, 0)
y <- c(y, 0)
z <- c(z, c)
res <- cbind(x, y, z)
res
}
tri2links<-function (tri)
{
res <- NULL
for (i in 1:nrow(tri)) {
resi <- list(c(tri[i, ][1], tri[i, ][2]), c(tri[i, ][1],
tri[i, ][3]), c(tri[i, ][2], tri[i, ][3]))
res <- c(res, resi)
}
res
}
library(Morpho)
library(rgl)
library(alphashape3d)
prova<-semielliss()
aprova<-ashape3d(prova,alpha=3)
plot(aprova)
close3d()
meshprova<-as.mesh3d(aprova)
links<-tri2links(t(meshprova$it))
points3d(prova)
#lineplot(prova,links) #### here you surely will have to stop before finishing as it is too slow....
close3d()
##### much faster
start <- prova[do.call(rbind, links)[, 1],]
end<- prova[do.call(rbind, links)[, 2], ]
purui <- do.call(rbind,Morpho::array2list(aperm(simplify2array(list(start,end)))))
segments3d(purui, lwd =2, col = 2)
Copied from email: Here a fully reproducible example with links grasped by the triangulation of a mesh. This is just an example with nearly non-sense links but sometimes links structure in 3D does not necessarily follow the lines of a triangulation and I think it is always desirable to draw them efficiently. Maybe you can consider to implement my solution in lineplot()