mapOnMesh | R Documentation |
For a given set of arbitrary coordinates, it returns the closest mesh vertices. This function is similar to the closemeshKD function provided by the Morpho package, but it's simpler and runs much faster (ca. 5-10x)
mapOnMesh(coords, mesh)
coords |
a data.frame-like object with 3D coordinates (1 per row). Only the first three columns will be used. |
mesh |
a target mesh3d object |
A data.frame object with target vertices extracted from mesh$vb and rownames set to the original vertex IDs
The output may differ from input landmarks already mapped to the mesh surface because this function returns the closest mesh vertex, not the closest point on the mesh surface (e.g. shortest distance to a mesh face)
library(Morpho)
data(demoFlake1)
alignedMesh<-pcAlign(demoFlake1$mesh)
# Note that the first coordinate is "inside" the object
coords<-data.frame(x=c(0,10,-3), y=c(0,10,3), z=c(5,10,10))
targets<-mapOnMesh(coords, alignedMesh)
require(rgl)
shade3d(alignedMesh, col="green")
points3d(coords, col="blue")
points3d(targets, col="red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.