interpolMesh {RRmorph} | R Documentation |
Interpolate values on a 3d mesh
Description
The function takes a reconstructed mesh3d
object
(sur
) with some related values
(to either triangles or
vertices of the mesh) and transfers such values to the real mesh
(refsur
) from which sur
was derived.
Usage
interpolMesh(sur,values,refsur,refmat,element=c("triangles","vertices"),k=4)
Arguments
sur |
a reconstructed |
values |
the vector of values related to |
refsur |
the reference mesh ( |
refmat |
the landmark set related to |
element |
one of |
k |
the number of nearest neighbor vertices used for interpolation (see details). |
Details
The function starts by locating a set of points (NNps) on
refsur
, each being the single nearest neighbor for each vertex of
sur
(or barycenter if element="triangles"
). Then,
interpolation is performed by identifying the k
points among NNps
being the closest to each vertex of refsur
and computing the mean of
their values
weighted by their distance.
Value
The vector of values related to each vertex of refsur
.
Author(s)
Marina Melchionna, Silvia Castiglione
Examples
da<-"https://github.com/pasraia/RRmorph_example_data/raw/refs/heads/main/RRmorphdata.rda"
download.file(url=da,destfile = paste0(tempdir(),"/RRmorphdata.rda"))
load(paste0(tempdir(),"/RRmorphdata.rda"))
require(rgl)
require(Morpho)
require(Rvcg)
pca<-procSym(endo.set)
ldm<-endo.set[,,"Homo_sapiens"]
sur<-endo.sur[["Homo_sapiens"]]
rec<- vcgBallPivoting(pca$mshape, radius = 0)
rec$vb[1:3,]<-t(ldm)
val1<-rnorm(ncol(rec$vb))
# Interpolate values associated to vertices
val1<-rnorm(ncol(rec$vb))
interp1<-interpolMesh(sur = rec,refsur = sur,refmat = ldm,
values = val1,element ="vertices",k = 4)
colmesh1<-col2mesh(mesh = sur,values = interp1,pal = heat.colors(5))
open3d()
shade3d(colmesh1,specular="black")
# Interpolate values associated to triangles
val2<-rnorm(ncol(rec$it))
interp2<-interpolMesh(sur = rec,refsur = sur,refmat = ldm,
values = val2,element ="triangles",k = 4)
colmesh2<-col2mesh(mesh = sur,values = interp2,pal = heat.colors(5))
open3d()
shade3d(colmesh2,specular="black")