GRASS GIS 7 Programmer's Manual  7.0.4(2016)-r00000
area_ellipse.c
Go to the documentation of this file.
1 
14 #include <math.h>
15 #include <grass/gis.h>
16 #include "pi.h"
17 
18 static struct state {
19  double E;
20  double M;
21 } state;
22 
23 static struct state *st = &state;
24 
25 /*
26  * a is semi-major axis, e2 is eccentricity squared, s is a scale factor
27  * code will fail if e2==0 (sphere)
28  */
29 
47 void G_begin_zone_area_on_ellipsoid(double a, double e2, double s)
48 {
49  st->E = sqrt(e2);
50  st->M = s * a * a * M_PI * (1 - e2) / st->E;
51 }
52 
63 double G_darea0_on_ellipsoid(double lat)
64 {
65  double x;
66 
67  x = st->E * sin(Radians(lat));
68 
69  return (st->M * (x / (1.0 - x * x) + 0.5 * log((1.0 + x) / (1.0 - x))));
70 }
71 
89 double G_area_for_zone_on_ellipsoid(double north, double south)
90 {
91  return (G_darea0_on_ellipsoid(north) - G_darea0_on_ellipsoid(south));
92 }
void G_begin_zone_area_on_ellipsoid(double a, double e2, double s)
Begin area calculations for ellipsoid.
Definition: area_ellipse.c:47
double G_area_for_zone_on_ellipsoid(double north, double south)
Calculates area between latitudes.
Definition: area_ellipse.c:89
double G_darea0_on_ellipsoid(double lat)
Calculate integral for area between two latitudes.
Definition: area_ellipse.c:63
struct state * st
Definition: parser.c:101
#define Radians(x)
Definition: pi.h:6
struct state state
Definition: parser.c:100