<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Method of a Point Localization in a Polygon in Relation to Ecological and Geographical Problems</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Andrey Tityapkin</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Ukrainian Scientific Center of Ecology of the Sea</institution>
          ,
          <addr-line>89 Frantsuzsky Blvd, Odessa, 65009</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The problem of point localization in an arbitrary polygon is considered in relation to the problems of geophysics and ecology. An analytical solution to the problem is obtained using mathematical analysis based on the Cauchy's integral formula from the theory of functions of a complex variable. On the basis of the obtained solution a program was developed for data sampling according to a given zoning of water areas, the further development of which will make it possible to assess the ecological state of the marine environment of Ukraine.</p>
      </abstract>
      <kwd-group>
        <kwd>1 Cauchy's integral formula</kwd>
        <kwd>polygon</kwd>
        <kwd>point localization</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        The zoning of the Black Sea, especially its
northwestern part, according to various ecological
and geographical processes or performed
according to a certain parameter, has been devoted
to a large number of works, in particular, this can
be found in the literature review of [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. The
relevance of the problem of zoning of sea areas is
due to the need to solve various theoretical and
practical problems: modeling and forecasting the
variability of climatic and ecological processes,
environmental quality management, planning
environmental measures, justification of
especially valuable territories, etc. [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. When the
boundaries of the regions are determined, an
equally urgent problem arises about the
distribution of the coordinates of the points of the
monitoring study or satellite observations and the
corresponding parameters over the given regions
for subsequent analysis. That is, the problem
arises about the point localization relative to a
certain area, as a rule, given by a polygon on a
plane. In general, this problem belongs to one of
the directions of computational geometry, known
as geometric search, in which it is customary to
distinguish two main problems: localization
problems and regional search problems. This task
belongs to the first type. It is relevant not only for
solving ecological and geographical problems. It
is related to information theory, computer
graphics, robotics, data protection and
compression, information security, video
surveillance, etc.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Brief description methods of the known</title>
      <p>
        Several algorithms are known for solving the
point localization problem in a polygon, the main
of them are ray tracing (counting the number of
intersections), summing angles, point localization
for convex and star polygons, stripe method, chain
method, triangulation detail method, trapezoid
method and others [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]-[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
      </p>
      <p>Ray tracing is one of the easiest ways to
determine whether a point belongs to an arbitrary
simple polygon. The algorithm is based on the
idea of counting the number of intersections of a
ray outgoing from a given point in the direction of
the horizontal axis, with the sides of a polygon. If
it is even, the point does not belong to the
polygon. A problem arises in the algorithm when
a ray crosses the vertex of a polygon or an edge
that partially coincides with the ray. The method
is simple, but generally not recommended.</p>
      <p>
        The summing angle method is also simple. The
algorithm is based on the idea of calculating the
sum of the signed angles formed at a given point
by the endpoints of each edge of a given polygon.
If the sum is close to zero, the point is outside the
polygon, if not, then it is inside. The number of
turns can be calculated by finding the closest
multiple of 2π. The problem with this scheme is
that it includes the square root, inverse cosine,
division, point, and cross product for each edge
tested. However, this method is very impractical,
as it requires calculating expensive operations for
each
edge
(inverse
trigonometric
functions,
square roots, division), and was even called the
"worst algorithm in the world" for this problem
[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>Point localization for convex and star polygons
can be determined using binary search. For a
convex polygon, segments are drawn from an
arbitrary point inside it to the vertices of the
polygon. Due to its convexity, the polygon will be
split into disjoint wedges. Wedges are ordered by
polar angle counterclockwise. Then a binary
search is applied for the desired wedge. After the
wedge is found, it is checked whether the point
lies inside the wedge or outside. The target point
lies inside the wedge if and only if a right turn is
performed. If the turn is left, then the specified
point is outside the polygon. A star polygon
contains at least one arbitrary point, such that the
segment from it to the desired point lies entirely
inside the polygon for any vertex from the
polygon. This method is quite laborious to
implement.</p>
      <p>One of the reasons for the wide variety of
methods for solving this problem is that each
known method, along with its advantages, has its
own disadvantages and limitations, which are
usually quite significant. Namely, this is the
occurrence of exceptional situations, slowness,
requirement of convexity, complexity in software
implementation.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Mathematical method of a point localization in a polygon</title>
      <p>
        In [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]-[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] a new approach is considered
based on the
      </p>
      <p>Cauchy's integral theorem</p>
      <p>
        and
formula from the theory of functions of a complex
variable. This approach was also discussed on the
forums [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] - [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. The following value is
calculated:
where Δ is the contour of a given polygon M,  0 =
 0 +   0 is a given point on the complex plane.
      </p>
      <p>From the Cauchy's formula (1) it follows that:</p>
      <p>0,   0 ∉ 
 = {2 ,   0 ∈</p>
      <p>∞,   0 ∈ ∆</p>
      <p>
        However, the final expression obtained in the
indicated
works
[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ],
      </p>
      <p>
        [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]-[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]
MATEMATICA
package turned
using
out to
the
be
incorrect, possibly
due to the
      </p>
      <p>cumbersome
calculations or a technical error. To verify this, it
is enough to consider an example from these
works and check if the point with coordinates
(1; 1) falls into the triangular region defined by
the points (0; 0), (0; 1), and (1; 0). In this work,
the correct expressions for calculating the value of
K are obtained using</p>
      <p>mathematical analysis,
without using special mathematical packages.</p>
      <p>The integral in (1) is represented as the sum of
two curvilinear integrals of the second kind:
 = ∫
∆
Thus,  ( , )
≡</p>
      <p>( ,  )
( ,  )</p>
      <p>)2]2
−2( −  0)( −  0
)</p>
      <p>( , ), so, the first integral in
(2) is equal to zero and expression (2) will now
take the following form:
+
,</p>
      <p>(1)
(2)
 = ∫
+ ∫</p>
      <p>+ ( −  0)
Let's find the partial derivatives:
 =  ∫
straight line passing through these two points
(segment) has the form:</p>
      <p>2
 21ℎ
where ℎ = ( 10 21 −  21 10), and, therefore, its
solution, the form of which after a series of
transformations, will be:
 0 +</p>
      <p>− 
1 −  0 + 
 0
1 −  0 +</p>
      <p>0
 0 −  0 + 1
 0 +  0 − 1</p>
      <p>+
 0
 0
whence we have the following expressions:
 =
 =
 2 −  1
 2 −  1 ( −  1)+  1, 
 2 −  1
 2 −  1 ( −  1)+  1, 
=  2 −  1  ,</p>
      <p>2 −  1
=  2 −  1  .</p>
      <p>2 −  1
 −  1 =
 2 −  1
 −  1
 2 −  1
,</p>
      <p>2
 1 ( −  0)2 + ( 2211 ( −  1)+  10) (4)</p>
      <p>Thus, the integral for side AB will be equal to
the following sum:
 ∫

 1 ( −  0)2 + ( 2211 ( −  1)+  10)</p>
      <p>2
= ∫</p>
      <p>2
 1  2 + ( 2211 ( −  10)+  10)
,
2 =
We will consider the first integral in the last given by the coordinates: (0; 0), (1; 0) and (0; 1),
we have the following expression:</p>
      <p>
        It's useful to note that in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] a solution to this
problem was also obtained, but in a different form,
because the method of shifting coordinates is used
there.
      </p>
      <p>
        For the test triangular region from [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]-[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ],
−
+
  +1,   +1,0 +   +1,   +1,0) ,
  ,0  +1, −   +1,   ,0
After transforming the denominator of the belong to the given triangular region, the point
It is easy to check that the point (1; 1) does not
integrand, we obtain the integral:
(0.25; 0.25) belongs to the region, and the point
(0.5; 0.5) belongs to the boundary.
      </p>
      <p>
        The considered mathematical method makes it
possible to solve the formulated problem of a
point localization with respect to curvilinear
polygonal regions. So, in studies [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] an
example is given in which a curvilinear boundary
given by an equation  =  2 is considered (Figure
1).
framework of the EMBLAS+ project, relatively
homogeneous water areas (sea water bodies),
presented in Figures 2 and 3, were identified to
carry out a basic assessment of the ecological state
of the marine environment in Ukraine [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ].
      </p>
      <p>From expression (3), we can obtain the
following integral of the function of a complex
variable for a parabola from 0 to 1:</p>
      <p>( −  0) − ( −  0)
∫  −  0 =  ∫ ( −  0)2 + ( −  0)2 =</p>
      <p>| =
1
=  ∫
0</p>
      <p>1
=  ∫
2 ( −  0)− ( 2 −  0)
( −  0)2 + ( 2 −  0)2</p>
      <p>=
 2 − 2</p>
      <p>0 +  0
( −  0)2 + ( 2 −  0)2 
0</p>
      <p>Solving the resulting integral, one can obtain
an expression for a given curvilinear side.</p>
      <p>The obtained solution (6) of the problem of a
point localization in a polygon is quite simple and
can be implemented in any suitable programming
language, for example, C ++, C #, Fortran,
Python. Unfortunately, the author of this work is
not aware of another similar analytical method for
solving this problem.</p>
      <p>Applied to ecological and geographical
problems, a program was developed in the C ++
language in the visual object-oriented
programming environment Borland C++Builder6,
which allows to distribute the coordinates of
points and the corresponding values of
hydrological and hydrochemical parameters
based on the results of monitoring or satellite
observations for further analysis of the ecological
state of sea waters in specified areas. Within the</p>
      <p>The coordinates of the peaks (longitude and
latitude) of each water area (polygon) were
entered into text files. Also, text files of satellite
observation data on temperature, chlorophyll,
transparency (longitude, latitude, parameter), as
well as monitoring observations were formed in
advance. The program first loads the coordinates
of the vertices of the polygon. Then the
observational data is loaded, a sample is
performed over a given area, and the results are
written to a new text file.</p>
      <p>Further work will be aimed at clarifying the
boundaries of these areas, especially coastal water
bodies. developing a software package based on
the developed program, which includes a database
of basic hydrological and hydrochemical
parameters for each water body. The database will
store a table of polygons with the following
columns: identifier, name and coordinates of the
polygon. Taking into account the fact that there
are a large number of zoning options for the Black
and Azov Seas according to various
characteristics, it is assumed that the database will
be able to provide the user with the ability to store
several zoning options. Such a software package
will make it possible to assess the long-term
dynamics of both average annual and monthly
average changes in the parameters of the marine
environment, the ecological state, eutrophication
trends and the quality of waters of specific water
bodies using the complex indicators E-TRIX and
BEAST. The author hopes that the results
obtained in this work will also find application in
geographic information systems.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusions</title>
      <p>
        As a result of the study, the following
conclusions were made:
 An analytical solution to the problem of
point localiziation in an arbitrary polygon is
obtained by methods of mathematical analysis
based on the Cauchy's integral formula
 As noted in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]-[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], this method can
be used for various curvilinear boundaries, as
well as when the point is near the boundary of
the region. Competing methods lead to the
need to compare practically equal numbers,
while in this method one has to compare values
that differ significantly in magnitude: 0, 2π, ∞
 In addition, this method does not require
the convexity of the polygon, unlike other
known methods of computational geometry
 A program has been developed to localize
the coordinates of points in the areas of
specific water bodies of the seas of Ukraine
 Prospects for further developments and
research in problems of geophysics and
ecology are considered
      </p>
    </sec>
    <sec id="sec-5">
      <title>5. References</title>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>I.D.</given-names>
            <surname>Loeva</surname>
          </string-name>
          (Ed.),
          <article-title>Hidrolohichni ta hidrohimichni pokaznyky stanu pivnichnozahidnoho shelfu Chornoho moria: dovidkovyi posibnyk [Hydrological and hydrochemical indicators of the status of the Black Sea's northwest shelf: reference guide]</article-title>
          .
          <source>Kyiv: KNT. (in Ukr.)</source>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>F.P.</given-names>
            <surname>Preparata</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.I. Shamos. Computational</given-names>
            <surname>Geometry</surname>
          </string-name>
          . An Introduction, SpringerVerlag, New York,
          <year>1985</year>
          . doi:
          <volume>10</volume>
          .1007/978- 1-
          <fpage>4612</fpage>
          -1098-6.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>A.I. Nedoshivina</surname>
          </string-name>
          ,
          <article-title>Ob algoritmakh lokalizatsii tochki otnositel'no razlichnykh ploskikh oblastey, Sovremennyye problemy yestestvennykh nauk [On algorithms of a point localization with respect to various plane regions, Modern problems of natural sciences]</article-title>
          , Vol.
          <volume>1</volume>
          (
          <issue>2</issue>
          ),
          <year>2014</year>
          , pp.
          <fpage>122</fpage>
          -
          <lpage>128</lpage>
          . (in Rus.)
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Eric</given-names>
            <surname>Haines</surname>
          </string-name>
          .
          <article-title>Point in Polygon Strategies</article-title>
          . URL: http://erich.realtimerendering.com/ptinpoly/
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>A.I.</given-names>
            <surname>Nedoshivina</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.M.</given-names>
            <surname>Sitnik</surname>
          </string-name>
          <article-title>Prilozheniya geometricheskikh algoritmov lokalizatsii tochki na ploskosti k modelirovaniyu i szhatiyu informatsii v zadachakh videonablyudeniy, Vestnik Voronezhskogo gosudarstvennogo tekhnicheskogo universiteta [Application of geometrical algorithms for point localization to modelling and data compression</article-title>
          , Voronezh State Technical University Bulletin], Vol.
          <volume>9</volume>
          (
          <issue>4</issue>
          ),
          <year>2013</year>
          , pp.
          <fpage>108</fpage>
          -
          <lpage>111</lpage>
          . (in Rus.)
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>A.I. Nedoshivina</surname>
          </string-name>
          ,
          <article-title>Primeneniye spetsial'nykh algoritmov lokalizatsii oblastey pri videonablyudeniyakh, Nauchnyye vedomosti</article-title>
          . Seriya: Matematika.
          <article-title>Fizika [Application of special algorithms for localization of areas in video surveillance</article-title>
          , Scientific statements], №
          <volume>17</volume>
          (
          <issue>214</issue>
          ), Issue 40,
          <year>2015</year>
          , pp.
          <fpage>162</fpage>
          -
          <lpage>164</lpage>
          . (in Rus.)
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>А.I. Nedoshivina</surname>
          </string-name>
          ,
          <article-title>Ob ispol'zovanii teorii funktsiy kompleksnogo peremennogo dlya lokalizatsii oblastey pri sokhranenii videoizobrazheniya, Teoriya i tekhnika radiosvyazi [On application of complex variables function theory for the areas localization under the conditions of saving video images]</article-title>
          <source>, № 2</source>
          ,
          <issue>2013</issue>
          , pp.
          <fpage>89</fpage>
          -
          <lpage>93</lpage>
          . (in Rus.)
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <article-title>[8] Algorithm for determining the hit of a point in the contour based on complex analysis. Community of IT specialists</article-title>
          . URL: https://habr.com/ru/post/125356/ (in Rus.)
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <article-title>[9] Does one figure lie inside another? Scientific forum dxdy</article-title>
          . URL: https://dxdy.ru/topic75167.html. (in Rus.)
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <article-title>Determination of belonging of a point to a closed contour. Forum of Russian Software Developer Network</article-title>
          . URL: http://rsdn.org/forum/alg/423435.all. (in Rus.)
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <article-title>Basic assessment of the ecological state of the marine environment of Ukraine</article-title>
          . URL: http://www.sea.gov.ua/uploads/Initial_Asse sment.pdf. (in Ukr.)
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>