Main Content

pointLocation

(Not recommended) Triangle or tetrahedron enclosing point

pointLocation(DelaunayTri) is not recommended. Use pointLocation(triangulation) instead.

DelaunayTri is not recommended. Use delaunayTriangulation instead.

Description

SI = pointLocation(DT,Q) returns the indices SI of the enclosing simplex (triangle/tetrahedron) for each query point location in matrix Q. The enclosing simplex for point Q(k,:) is SI(k). pointLocation returns NaN for all points outside the convex hull.

example

SI = pointLocation(DT,QX,QY) and SI = pointLocation(DT,QX,QY,QZ) allow the query point locations to be specified in column vector format when working in 2-D and 3-D.

[SI,BC] = pointLocation(___) returns the barycentric coordinates BC.

example

Examples

collapse all

Create a 2-D Delaunay triangulation for a set of random points.

rng default
X = rand(10,2);
dt = DelaunayTri(X);

Find the triangles that contain specified query points.

Q = [0.25 0.25; 0.5 0.5];
triids = pointLocation(dt,Q)
triids = 2×1

     2
     7

Create a 3-D Delaunay triangulation for a set of random points.

rng default
x = rand(10,1); 
y = rand(10,1); 
z = rand(10,1);
dt = DelaunayTri(x,y,z);

Find the triangles that contain specified query points and evaluate the barycentric coordinates.

Q = [0.25 0.25 0.25; 0.5 0.5 0.5];
[tetids, bcs] = pointLocation(dt,Q)
tetids = 2×1

   NaN
     3

bcs = 2×4

       NaN       NaN       NaN       NaN
    0.2255    0.3823    0.2182    0.1739

Input Arguments

collapse all

Delaunay triangulation representation, specified as a DelaunayTri object.

Query points, specified as a matrix. Q is of size mpts-by-ndim, where mpts is the number of query points and ndim the dimension of the space where the points reside.

Query points, specified as separate column vectors. Specify QX and QY to give the coordinates of 2-D query points, or specify QX, QY, and QZ to give the coordinates of 3-D query points.

Output Arguments

collapse all

Indices of enclosing simplex, returned as a column vector. SI is a vector of length mpts containing the indices of the enclosing simplex for each query point. mpts is the number of query points.

Barycentric coordinates of query point, returned as a matrix. BC is a mpts-by-ndim matrix where each row BC(i,:) represents the barycentric coordinates of query point Q(i,:) with respect to the enclosing simplex SI(i).

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced in R2009a