A Code for Generating Edge Points of a Plane Domain with Complex Geometric Shape ()
1. Introduction
The physical problems encountered are generally governed by non-linear partial differential equations. The existence and uniqueness of solutions for these problems have been studied by Haim Brezis [1]. Available analytical methods are limited, that’s why we have to resort to numerical methods based on algorithms. The pseudo-spectral method [2] [3] is an excellent methods for solving these problems, but it has the disadvantage to take into account edge conditions for plane domains with complex geometrical shapes. In response to this difficulty, we have developed a numerical code in MatLab called “onpolygon” to facilitate the treatment of the edges of a plane domain with a complex geometric shape. Note that similar work has been approached in our previous works [4] [5]. We can also cite the work of Amann, who also approaches the problem of edges [6] [7]. This code is a contribution to the treatment of the edges of a plane domains with complex geometries shape, such as lakes, rivers, basins etc.
2. Theoretical Approach
We consider any point
located at a distance
from any segment of the polygon to be a point on the edge of the polygon. Let
,
two consecutive vertices of the polygon and P any point of the polygon, P is assimilated to a point of the segment
if the distance which separates it from the line
is smaller or equal to
and it belongs to the circle of diameter
. We explain here how these two conditions can be translated analytically [4].
2.1. Distance from a Point to a Line Passing through Two Points
Let
,
,
three given points, H the orthogonal project of P on the line of equation:
passing through the two points
,
. Thus, the distance from P to
is PH and is given by:
And yet we have:
This gives us
, and therefore
2.2. Points on the Segments
Consider N points
and
of any points in the plane represented by Figure 1 below.
Figure 1. Illustrative diagram of the projection of any point in the plane onto a line segment.
We have
,
,
, and
Let’s put
the coordinates of segment ends and,
the coordinates of the points in the plane. For matrix programming, we consider the following matrices
In MatLab, these matrices are obtained using the following command lines:
The repmat command creates a large array in which each block is identical to the array passed as the first argument; the two other arguments respectively represent the number of times the argument-matrix is repeated according to the columns, respectively along the lines [5]. In order to define the conditions under which any point in the plane can be assimilated to a point on the segment, and above all to optimize our calculation codes, we need to set the following conditions
It follows from these notations that the determinant is calculated using the command line:
>> DET=Zx.*repmat(Ky,1,m)-Zy.*repmat(Kx,1,m) et a = sqrt(sum([Kx0;Ky0].2))
The vector
of distances is then obtained using the following MatLab command:
(1)
The condition for any point
in the plane to be considered a point or infinitely close to the line D passing through the points
,
is given by:
(2)
To this condition, we add the condition for this point to be in the circle of diameter
. Simply put:
In MatLab, these matrices can be written using command lines:
Posing
, then the condition for a point
in the circle of diameter
is written:
(3)
This is a component-by-component multiplication and
is the transpose of
. This translates into MatLab language by:
2.3. Presentation of Developed Code
For a given set of domain points, this code identifies which are on the edge and which are not. The developed code is as follows:
Executing this code is very simple. Simply give [X, Y] the vertices coordinates of the complex domain assimilated to a polygon and [Xp, Yp] any point of this domain. The code we’ve developed automatically generates the indices of the edge points, enabling us to extract the points we’re looking for.
Figure 2. On the left, the exterior points and the points of the non-tensor domain obtained by MatLab’s integrated code inpolygon and on the right, the interior and the edge points of the non-tensor domain obtained by onpolygon code.
3. Illustration of Developed Code
An illustration of this code is shown in the figure below. In the following illustration, we consider a polygon with vertices (2, 1); (0, 2); (1, 4); (2, 5); (4, 4); (5, 5); (6, 3); (5, 1); (4, 0) and (3, 2). First, we use the MatLab’s integrated code inpolygon, which distinguishes between the points of the polygon and the external points (see Figure 2 in left). The points within the domain are shown in red and the external points in blue. Next, we apply our code onpolygon to identify the interior and the edge points. These points are shown in red and blue, respectively (see Figure 2 in right).
4. Conclusion and Remarks
This code extracts the indices of edge and interior points. It’s a complement of MatLab’s integrated code “inpolygon”, which enables edge conditions of either Dirichlet or Neumann type to be handled. The difference between our developed code and MatLab’s integrated code is that our code determines the indices of the interior and the edge points, whereas MatLab’s integrated code gives the indices of the polygon points (including inner points and edges) and the indices of the outer points. The combination of these two codes generates complete indices for interior, edge and exterior points.