GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
area_poly2.c
Go to the documentation of this file.
1 
17 #include <grass/gis.h>
18 
19 
29 double G_planimetric_polygon_area(const double *x, const double *y, int n)
30 {
31  double x1, y1, x2, y2;
32  double area;
33 
34  x2 = x[n - 1];
35  y2 = y[n - 1];
36 
37  area = 0;
38  while (--n >= 0) {
39  x1 = x2;
40  y1 = y2;
41 
42  x2 = *x++;
43  y2 = *y++;
44 
45  area += (y2 + y1) * (x2 - x1);
46  }
47 
48  if ((area /= 2.0) < 0.0)
49  area = -area;
50 
51  return area;
52 }
double G_planimetric_polygon_area(const double *x, const double *y, int n)
Calculates planimetric polygon area.
Definition: area_poly2.c:29
int y
Definition: plot.c:34
int n
Definition: dataquad.c:291