closemeshKD: Project coordinates onto a target triangular surface mesh.

View source: R/closemeshKD.r

closemeshKDR Documentation

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.

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.

Value

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 method=1, this is not the Euclidean distance but the distance of the reference point to the faceplane (orthogonally projected) plus the distance to the closest point on one of the face's edges (the target point). See the literature cited below for details.

it

4xm matrix containing vertex indices forming triangular faces.Only available, when x is a mesh

Author(s)

Stefan Schlager

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


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)


Morpho documentation built on June 22, 2024, 7:19 p.m.