GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
Main Page
Related Pages
+
Data Structures
Data Structures
Class Hierarchy
+
Data Fields
+
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
+
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
+
Files
File List
+
Globals
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
x
y
+
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
o
p
r
s
t
u
v
w
y
z
+
Enumerations
a
c
d
e
h
l
m
n
o
p
r
s
t
v
y
+
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
+
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
area_poly2.c
Go to the documentation of this file.
1
/*!
2
* \file lib/gis/area_poly2.c
3
*
4
* \brief GIS Library - Planimetric polygon area calculation routines.
5
*
6
* (C) 2001-2009 by the GRASS Development Team
7
*
8
* This program is free software under the GNU General Public License
9
* (>=v2). Read the file COPYING that comes with GRASS for details.
10
*
11
* \author Original author CERL
12
*/
13
14
#include <
grass/gis.h
>
15
16
/*!
17
* \brief Calculates planimetric polygon area.
18
*
19
* \param x array of x values
20
* \param y array of y values
21
* \param n number of x,y pairs
22
23
* \return polygon area in map units
24
*/
25
double
G_planimetric_polygon_area
(
const
double
*
x
,
const
double
*y,
int
n)
26
{
27
double
x1, y1, x2, y2;
28
double
area;
29
30
x2 = x[n - 1];
31
y2 = y[n - 1];
32
33
area = 0;
34
while
(--n >= 0) {
35
x1 = x2;
36
y1 = y2;
37
38
x2 = *x++;
39
y2 = *y++;
40
41
area += (y2 + y1) * (x2 - x1);
42
}
43
44
if
((area /= 2.0) < 0.0)
45
area = -area;
46
47
return
area;
48
}
G_planimetric_polygon_area
double G_planimetric_polygon_area(const double *x, const double *y, int n)
Calculates planimetric polygon area.
Definition:
area_poly2.c:25
x
#define x
gis.h
lib
gis
area_poly2.c
Generated on Mon May 31 2021 05:21:27 for GRASS GIS 7 Programmer's Manual by
1.8.13