trirectangle


Untitled

Triangulation of a rectangular area

Syntax

TR = trirectangle(R,Nx,Ny,trisub)

Description

TR = trirectangle(R,Nx,Ny,trisub) returns a triangulation of a rectangle R, specified as a four-element vector of the form [x y w h] (explained below), by first subdiving R into a set of Nx*Ny sub-rectangles of width w/Nx and height h/Ny and then splitting each rectangle into a set of triangles as specified by the character string trisub, where options for the subdivision of each subrectangle into triangles are illustrated in the examples below.
As noted above, the input retangle R is specified as a four-element vector of the form [x y w h], where x and y define the coordinate for the lower left corner of R and w and h define the dimensions of the rectangle in the x and y directions, respectively, i.e., the width and height.

Examples

Example 1 Generating a (structured) triangulation of a rectangular area
The trirectangle function provides a simple way to generate different structured triangulation patterns over a rectangle. The pattern of the triangulation is controlled by the trisub character string, which currently has four options:
TR = trirectangle([0,0,1,1],5,4,‘/’);
triplot(TR,‘LineWidth’,2); title(‘trisub = ”/”’);
TR = trirectangle([0,0,1,1],5,4,‘\’);
triplot(TR,‘LineWidth’,2); title(‘trisub = ”\\”’);
TR = trirectangle([0 0,1,1],5,4,‘X’);
triplot(TR,‘LineWidth’,2); title(‘trisub = ”X”’);
TR = trirectangle([0 0,1,1],5,4,‘X-X’);
triplot(TR,‘LineWidth’,2); title(‘trisub = ”X-X”’);
Example 2 Generating a sequence of uniformly refined triangulations of a rectangular area
In combination with the trirefine function, the trirectangle function provides a simple means to generate a sequence of uniformly refined triangulations of a rectangular area that can be used, for example, for finite element convergence studies.
Consider, for example, a triangulation of the bi-unit square generated using the trirectangle function as follows:
TR = cell(4,1);
TR{1} = trirectangle([-1,1,2,2],3,3,‘/’);
which is stored in cell array that will contain a sequence of three refinements that can be obtained using the trirefine function, i.e.,
[TR{2:4}] = trirefine(TR{1},3);
Plotting the sequence of meshes
for i = 1:length(TR)
subplot(2,2,i); triplot(TR{i});
daspect([1 1 1]);
title([‘Triangulation ‘,num2str(i)]);
end

This function is part of……..

TriTools_Logo.png