Learn R Programming

Morpho (version 1.0-1)

closemeshKD: Project coordinates onto a target triangular surface mesh.

Description

For a set of 3D-coordinates the closest matches on a target surface are determined and normals at as well as distances to that point are calculated.

Usage

closemeshKD(x, mesh, k = 50, sign = FALSE, barycoords=FALSE, cores = 1, method = 0, ...)

Arguments

x
k x 3 matrix containing 3D-coordinates or object of class mesh3d.
mesh
triangular surface mesh stored as object of class mesh3d.
k
neighbourhood of kd-tree 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 TRUE, barycentric coordinates of the hit points are returned.
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.

Value

  • returns an object of class mesh3d. with:
  • vb4xn matrix containing n vertices as homolougous coordinates.
  • normals4xn matrix containing vertex normals.
  • qualityvector: containing distances to target.
  • it4xm matrix containing vertex indices forming triangular faces.Only available, when x is a mesh.

Details

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.

References

Baerentzen, Jakob Andreas. & Aanaes, H., 2002. Generating Signed Distance Fields From Triangle Meshes. Informatics and Mathematical Modelling.

Moshfeghi M, Ranganath S, Nawyn K. 1994. Three-dimensional elastic matching of volumes IEEE Transactions on Image Processing: A Publication of the IEEE Signal Processing Society 3:128-138.

See Also

ply2mesh

Examples

Run this code
require(rgl)
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)

Run the code above in your browser using DataLab