closemeshKD  R Documentation 
For a set of 3Dcoordinates the closest matches on a target surface are determined and normals at as well as distances to that point are calculated.
closemeshKD(
x,
mesh,
k = 50,
sign = FALSE,
barycoords = FALSE,
cores = 1,
method = 0,
...
)
x 
k x 3 matrix containing 3Dcoordinates or object of class

mesh 
triangular surface mesh stored as object of class 
k 
neighbourhood of kdtree to search  the larger, the slower  but the more likely the absolutely closest point is hit. 
sign 
logical: if TRUE, signed distances are returned. 
barycoords 
logical: if 
cores 
integer: how many cores to use for the search algorithm. 
method 
integer: either 0 or 1, if 0 ordinary Euclidean distance is used, if 1, the distance suggested by Moshfeghi(1994) is calculated. 
... 
additional arguments. currently unavailable. 
The search for the clostest point is designed as follows: Calculate the barycenter of each target face. For each coordinate of x, determine the k closest barycenters and calculate the distances to the closest point on these faces.
returns an object of class mesh3d
. with:
vb 
4xn matrix containing n vertices as homolougous coordinates 
normals 
4xn matrix containing vertex normals 
quality 
vector: containing distances to target. In case of 
it 
4xm matrix containing vertex indices forming triangular faces.Only available, when x is a mesh 
Stefan Schlager
Baerentzen, Jakob Andreas. & Aanaes, H., 2002. Generating Signed Distance Fields From Triangle Meshes. Informatics and Mathematical Modelling.
Moshfeghi M, Ranganath S, Nawyn K. 1994. Threedimensional elastic matching of volumes IEEE Transactions on Image Processing: A Publication of the IEEE Signal Processing Society 3:128138.
ply2mesh
data(nose)
out < closemeshKD(longnose.lm,shortnose.mesh,sign=TRUE)
### show distances  they are very small because
###longnose.lm is scaled to unit centroid size.
hist(out$quality)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.