Learn R Programming

Morpho (version 2.12)

mcNNindex: find nearest neighbours for 2D and 3D point clouds

Description

find nearest neighbours for point clouds using a kd-tree search. This is just a wrapper of the function vcgKDtree from package Rvcg. Wwraps the function vcgKDtree from package 'Rvcg' (for backward compatibility )

Usage

mcNNindex(target, query, cores = parallel::detectCores(), k = k, ...)

Value

l x k matrix containing indices of closest points.

Arguments

target

k x m matrix containing data which to search.

query

l x m matrix containing data for which to search.

cores

integer: amount of CPU-cores to be used. Only available on systems with OpenMP support.

k

integer: how many closest points are sought.

...

additional arguments - currently unused.

See Also

closemeshKD

Examples

Run this code

require(rgl)
data(nose)
# find closest vertex on surface for each landmark
clost <- mcNNindex(vert2points(shortnose.mesh),shortnose.lm, k=1,
mc.cores=1)
if (FALSE) {
spheres3d(vert2points(shortnose.mesh)[clost,],col=2,radius=0.3)
spheres3d(shortnose.lm,radius=0.3)
wire3d(shortnose.mesh)
}

Run the code above in your browser using DataLab