Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
26
Добавлен:
09.02.2015
Размер:
290.82 Кб
Скачать

Delaunay Triangulation.

<DelaunayTri> - Creates a Delaunay triangulation from a set of points

DelaunayTri Creates a Delaunay triangulation from a set of points

DelaunayTri is used to create a Delaunay triangulation from a set of

points in 2D/3D space. A 2D Delaunay triangulation of a set of points

ensures that the circumcircle associated with each triangle contains

no other point in its interior. This definition extends naturally to

higher dimensions. With DelaunayTri you can incrementally modify the

triangulation by adding or removing points. You can also perform

topological and geometric queries, compute the Voronoi diagram, and

convex hull. In 2D triangulations you can impose edge constraints

between pairs of points.

DT = DelaunayTri() creates an empty Delaunay triangulation.

DT = DelaunayTri(X), DelaunayTri(X, Y), DelaunayTri(X, Y, Z) creates a

Delaunay triangulation from a set of points. The points can be specified

as an mpts-by-ndim matrix X, where mpts is the number of points and ndim

is the dimension of the space where the points reside, 2 <= ndim <= 3.

Alternatively, the points can be specified as column vectors (X,Y) or

(X,Y,Z) for 2D and 3D input.

DT = DelaunayTri(..., C) creates a constrained Delaunay triangulation.

The edge constraints C are defined by an numc-by-2 matrix, numc being

the number of constrained edges. Each row of C defines a constrained

edge in terms of its endpoint indices into the point set X. This feature

is only supported for 2D triangulations.

Example: Compute the Delaunay triangulation of twenty random points

located within a unit square.

x = rand(20,1);

y = rand(20,1);

dt = DelaunayTri(x,y)

triplot(dt);

Further examples: Follow the link to demoDelaunayTri in the

see also section.

DelaunayTri methods:

convexHull - Returns the convex hull

voronoiDiagram - Returns the Voronoi diagram

nearestNeighbor - Search for the point closest to the specified location

pointLocation - Locate the simplex containing the specified location

inOutStatus - Returns the in/out status of the triangles in a 2D constrained Delaunay

DelaunayTri inherited methods:

DelaunayTri inherits all the methods of TriRep.

Refer to the help for TriRep for a list of these methods.

DelaunayTri properties:

Constraints - The imposed edge constraints – 2D only

X - The coordinates of the points in the triangulation

Triangulation - The computed triangulation

See also demoDelaunayTri, TriRep, triplot, trisurf, tetramesh, TriScatteredInterp.

Reference page in Help browser

doc DelaunayTri

<DelaunayTri/convexHull> - Returns the convex hull

convexHull Returns the convex hull

K = convexHull(DT) returns the indices into the array of points DT.X

that correspond to the vertices of the convex hull. If the points lie

in 2D space, K is a column vector of length numf, otherwise K is a

matrix of size numf-by-ndim, numf being the number of facets in the

convex hull, and ndim the dimension of the space where the points reside.

[K AV] = convexHull(DT) returns in addition, the area/volume bounded

by the convex hull.

Example 1: Compute the convex hull of a set of random points located

within a unit square in 2D space.

x = rand(10,1)

y = rand(10,1)

dt = DelaunayTri(x,y)

k = convexHull(dt)

plot(dt.X(:,1),dt.X(:,2), '.', 'markersize',10); hold on;

plot(dt.X(k,1),dt.X(k,2), 'r'); hold off;

Example 2: Compute the convex hull of a set of random points located

within a unit cube in 3D space, and the volume bounded by the

convex hull.

X = rand(25,3)

dt = DelaunayTri(X)

[ch v] = convexHull(dt)

trisurf(ch, dt.X(:,1),dt.X(:,2),dt.X(:,3), 'FaceColor', 'cyan')

See also DelaunayTri, trisurf.

Reference page in Help browser

doc DelaunayTri/convexHull

<DelaunayTri/inOutStatus> - Returns the in/out status of the triangles in a 2D constrained Delaunay

inOutStatus Returns the in/out status of the triangles in a 2D constrained Delaunay

IN = inOutStatus(DT) returns the in/out status of the triangles in a

2D constrained Delaunay triangulation of a geometric domain.

IN is a logical array of length equal to the number of triangles in

the triangulation. The constrained edges in the triangulation define

the boundaries of a valid geometric domain.

Given a Delaunay triangulation that has a set of constrained edges that define

a bounded geometric domain. The i'th triangle in the triangulation is classified

as inside the domain if IN(i) equals 1, otherwise the triangle outside.

Note: inOutStatus is only relevant for 2D constrained Delaunay triangulations

where the imposed edge constraints bound a closed geometric domain.

Example:

% Create a geometric domain that consists of a square with a square hole

outerprofile = [-5 -5; -3 -5; -1 -5; 1 -5; 3 -5; 5 -5;...

5 -3; 5 -1; 5 1; 5 3;...

5 5; 3 5; 1 5; -1 5; -3 5; -5 5;...

-5 3; -5 1; -5 -1; -5 -3; ];

innerprofile = outerprofile.*0.5;

profile = [outerprofile; innerprofile];

outercons = [(1:19)' (2:20)'; 20 1;];

innercons = [(21:39)' (22:40)'; 40 21];

edgeconstraints = [outercons; innercons];

% Create a constrained Delaunay triangulation of the domain

dt = DelaunayTri(profile, edgeconstraints)

subplot(1,2,1);

triplot(dt);

hold on;

plot(dt.X(outercons',1), dt.X(outercons',2), '-r', 'LineWidth', 2);

plot(dt.X(innercons',1), dt.X(innercons',2), '-r', 'LineWidth', 2);

axis equal;

title(sprintf('Plot showing interior and exterior\n triangles with respect to the domain.'));

hold off;

subplot(1,2,2);

inside = inOutStatus(dt);

triplot(dt(inside, :), dt.X(:,1), dt.X(:,2));

hold on;

plot(dt.X(outercons',1), dt.X(outercons',2), '-r', 'LineWidth', 2);

plot(dt.X(innercons',1), dt.X(innercons',2), '-r', 'LineWidth', 2);

axis equal;

title(sprintf('Plot showing interior triangles only\n'));

hold off;

Reference page in Help browser

doc DelaunayTri/inOutStatus

<DelaunayTri/nearestNeighbor> - Search for the point closest to the specified location

nearestNeighbor Search for the point closest to the specified location

PI = nearestNeighbor(DT, QX) returns the index of nearest point in

DT.X for each query point location in QX. The matrix QX is of size

mpts-by-ndim, mpts being the number of query points and ndim the

dimension of the space where the points reside. PI is a column vector

of point indices that index into the points DT.X. The length of PI is

equal to the number of query points mpts.

PI = nearestNeighbor(DT, QX,QY) and PI = nearestNeighbor(DT, QX,QY,QZ)

allow the query points to be specified in alternative column vector

format when working in 2D and 3D.

[PI, D] = nearestNeighbor(DT,...) returns in addition, the corresponding

Euclidean distances D between the query points and their nearest

neighbors. D is a column vector of length mpts.

Note: nearestNeighbor is not supported for 2D triangulations that have

constrained edges.

Example:

x = rand(10,1)

y = rand(10,1)

dt = DelaunayTri(x,y)

% Find the points nearest the following query points

qrypts = [0.25 0.25; 0.5 0.5]

pid = nearestNeighbor(dt, qrypts)

See also DelaunayTri, DelaunayTri/pointLocation.

Reference page in Help browser

doc DelaunayTri/nearestNeighbor

<DelaunayTri/pointLocation> - Locate the simplex containing the specified location

pointLocation Locate the simplex containing the specified location

SI = pointLocation(DT, QX) returns the indices SI of the enclosing

simplex (triangle/tetrahedron, etc) for each query point location in QX.

The enclosing simplex for point QX(k,:) is SI(k). The matrix QX is of

size mpts-by-ndim, mpts being the number of query points. SI is a

column vector of length mpts. pointLocation returns NaN for all points

outside the convex hull.

SI = pointLocation(DT, QX,QY) and SI = pointLocation (DT, QX,QY,QZ)

allow the query point locations to be specified in alternative column

vector format when working in 2D and 3D.

[SI, BC] = pointLocation(DT,...) returns in addition, the Barycentric

coordinates BC. BC is a mpts-by-ndim matrix, each row BC(i,:) represents

the Barycentric coordinates of QX(i,:) with respect to the enclosing

simplex SI(i).

Example 1:

% Point Location in 2D

X = rand(10,2)

dt = DelaunayTri(X)

% Find the triangles that contain the following query points

qrypts = [0.25 0.25; 0.5 0.5]

triids = pointLocation(dt, qrypts)

Example 2:

% Point Location in 3D plus barycentric coordinate evaluation

x = rand(10,1); y = rand(10,1); z = rand(10,1);

dt = DelaunayTri(x,y,z)

% Find the triangles that contain the following query points

qrypts = [0.25 0.25 0.25; 0.5 0.5 0.5]

[tetids, bcs] = pointLocation(dt, qrypts)

See also DelaunayTri, DelaunayTri/nearestNeighbor.

Reference page in Help browser

doc DelaunayTri/pointLocation

<DelaunayTri/voronoiDiagram> - Returns the Voronoi diagram

voronoiDiagram Returns the Voronoi diagram

The Voronoi diagram of a discrete set of points X decomposes the space

around each point X(i) into a region of influence R{i}. Locations within

the region R{i} are closer to point i than any other point in X. The

region of influence is called the Voronoi region. The collection of all

the Voronoi regions is the Voronoi diagram.

[V, R] = voronoiDiagram(DT) returns the vertices V and regions R of

the Voronoi diagram of the points DT.X. The region R{i} is a cell array

of indices into V that represents the Voronoi vertices bounding the

region. V is a numv-by-ndim matrix representing the coordinates of the

Соседние файлы в папке Библиотеки Matlab