TriTools: A Triangulation Toolbox for Matlab®


Untitled

Developed at The Computational Hydrodynamics and Informatics Laboratory (The CHIL) at The Ohio State University, TriTools provides a collection of functions intended to expand the existing collection of triangulation (tri) functions and methods that act on objects of the triangulation class already available in MATLAB®, which include, for example, triplot, trisurf, vertexAttachments, etc. With its extensive documentation, which includes a number of worked examples, it is also meant to serve as an educational resource for students and researchers.

Functions

The triangulation functions currently available in TriTools include:
Detailed descriptions of each tri function, with examples, are available in the links above. Two important things of note: (1) The functions are not, strictly speaking, methods of the triangulation class (as they are not part of the built-in MATLAB® class definition). Therefore, they cannot be invoked using the dot notation, as can be done with the existing triangulation class methods, e.g., TR.vertexAttachments; (2) The functions are currently limited to 2-D triangulations. Future versions of TriTools may include extensions to the 3-D case.

General Description

Use of the functions in TriTools requires a basic knowledge of the MATLAB® triangulation class, which provides an array-based representation of triangulations in two and three dimensions, on which one can perform a variety of geometric and topological queries using the built-in triangulation class methods or object functions. This triangulation representation is stored in two so-called class properties:
  1. Points — an array that stores the coordinates of the points (vertices) in the triangulation. The
  2. ConnnectivityList — an array in which each row stores the vertex IDs that define the triangles or tetrahedra that make up the triangulation.
The figure below illustrates the representation of a simple (2-D) triangulation object TR.
test7.png
Note that the point (vertex) and triangle (element) IDs are not explicitly stored in the Points and ConnectivityList, respectively; instead, the row numbers of the arrays serve as the respective IDs.
One way to construct a triangulation object is by invoking the triangulation function (or constructor method). For example, given a point set P and a triangle connectivity list T, e.g.,
P = [1.0 1.0; 2.0 1.0; 3.0 1.0; 1.5 1+sqrt(3/4); 2.5 1+sqrt(3/4)];
T = [1 2 4; 2 5 4; 2 3 5 ];
a triangulation object TR can be constructed by
TR = triangulation(T,P)
TR =
triangulation with properties:

Points: [5×2 double]
ConnectivityList: [3×3 double]

and a plot of the triangulation can be obtained by
triplot(TR); daspect([1 1 1])
Given the triangulation object, one can then perform a variety of geometric and topological queries using the built-in triangulation class methods (see the triangulation help documentation for a complete list). For example, the coordinates of the circumcenters for each triangle (element) in the triangulation can be obtained via
C = circumcenter(TR)
C = 3×2
1.5000 1.2887
2.0000 1.5774
2.5000 1.2887
or, since circumcenter is a built-in triangulation class method, by invoking the dot notation, i.e.,
C = TR.circumcenter
C = 3×2
1.5000 1.2887
2.0000 1.5774
2.5000 1.2887
This is an example of a geometric query. As an example of a topological query, consider the isConnected function, which returns a logical value indicating whether node pairs are connected by an edge (1,true) or not (0,false), e.g.,
isConnected(TR,1,2)
ans = logical
1
isConnected(TR,1,3)
ans = logical
0
The functions trigeometry and tritopology of TriTools were created to expand the list of geometric and topological queries that can be performed on triangulation class objects. For example, the area of each triangle in TR can be obtained via
%A = trigeometry(TR,’area’)
(As noted above, given that these are not built-in triangulation class methods, they cannot be invoked using the dot notation. An alternative solution would be to create a separate “triangulation-like” class that mimics the MATLAB® triangulation class in all existing respects while providing additional class methods.) In a similar way, a number of additional topological queries can be performed using the tritopology function (see the tritopology documentation for details). The remaining functions in TriTools provide means to contruct simple triangulations (trirectangle) or to operate on existing triangulations to produce modified triangulations (triextract and trirefine).