Documentation Center

  • Trial Software
  • Product Updates

pointLocation

Class: delaunayTriangulation

Triangle or tetrahedron containing specified location

Syntax

ti = pointLocation(DT,QP)
ti = pointLocation(DT,qx,qy)
ti = pointLocation(DT,qx,qy,qz)
[ti,B] = pointLocation(___)

Description

ti = pointLocation(DT,QP) returns the enclosing triangles or tetrahedra for each query point in QP. Each row in matrix QP contains the x, y, (and possibly z) coordinates of a query point.

ti = pointLocation(DT,qx,qy) specifies the x and y coordinates of the query points in 2-D as separate column vectors.

ti = pointLocation(DT,qx,qy,qz) specifies the x, y, z coordinates of the query points in 3-D as separate column vectors.

[ti,B] = pointLocation(___) also returns the barycentric coordinates of each query point with respect to its enclosing triangle or tetrahedron. You can specify both output arguments with any of the previous syntaxes.

Input Arguments

DT

A Delaunay triangulation, see delaunayTriangulation.

QP

Query points, specified as a matrix whose columns are the x, y, (and possibly z) coordinates of the points to query.

qx

Query x-coordinates, specified as a column vector containing the x-coordinates of the points to query.

qy

Query y-coordinates, specified as a column vector containing the y-coordinates of the points to query.

qz

Query z-coordinates, specified as a column vector containing the z-coordinates of the points to query.

Output Arguments

ti

IDs of enclosing triangles or tetrahedra, returned as a column vector. Each element in ti is the ID of a triangle or tetrahedron that encloses a query point. ti(k) encloses the kth query point.

pointLocation returns NaN values for any points outside the convex hull.

B

Barycentric coordinates, returned as matrix. The values at B(j,:) are the barycentric coordinates of the jth query point with respect to ti(j).

Definitions

Triangle or Tetrahedron ID

A row number of the matrix, DT.ConnectivityList. Use this ID to refer a specific triangle or tetrahedron.

Examples

expand all

Find Enclosing Triangles in 2-D

Create a Delaunay triangulation from a set of random points.

x = gallery('uniformdata',[20 1],0);
y = gallery('uniformdata',[20 1],1);
DT = delaunayTriangulation(x,y);

Define two query points.

QP = [0.25 0.25; 0.5 0.5];

Find the IDs of the enclosing triangles for each query point.

ti = pointLocation(DT,QP)
ti =

     8
     7

Examine the connectivity of the enclosing triangles.

DT.ConnectivityList(ti,:)
ans =

    19    15     8
     4    10     6

Find Enclosing Tetrahera and Barycentric Coordinates in 3-D

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

x = gallery('uniformdata',[20 1],0);
y = gallery('uniformdata',[20 1],1);
z = gallery('uniformdata',[20 1],2);
DT = delaunayTriangulation(x,y,z);

Find the tetrahedra that enclose the query points and calculate the barycentric coordinates of the query points.

QP = [0.7 0.6 0.3; 0.5 0.5 0.5];
[ti,B] = pointLocation(DT,QP)
ti =

    57
    56

B =

    0.2796    0.0184    0.5286    0.1734
    0.3687    0.0149    0.5343    0.0821

See Also

|

Was this topic helpful?