area_ellipse.c

Go to the documentation of this file.
00001 #include <math.h>
00002 #include "pi.h"
00003 #include "gis.h"
00004 
00005 static double E;
00006 static double M;
00007 
00008 /*
00009  * a is semi-major axis, e2 is eccentricity squared, s is a scale factor
00010  * code will fail if e2==0 (sphere)
00011  */
00012 
00031 int G_begin_zone_area_on_ellipsoid (double a,double e2,double s)
00032 {
00033     E = sqrt(e2);
00034     M = s * a * a * PI * (1 - e2) / E;
00035 
00036     return 0;
00037 }
00038 
00039 /*
00040  * this routine is part of the integral for the area between two latitudes
00041  */
00042 double
00043 G_darea0_on_ellipsoid (register double lat)
00044 {
00045     register double x;
00046 
00047     x = E * sin (Radians(lat));
00048 
00049     return (M* (x/(1.0-x*x) + 0.5*log((1.0+x)/(1.0-x))));
00050 }
00051 
00052 /*
00053  * this routine shows how to calculate area between two lats, but
00054  * isn't efficient for row by row since G_darea0() will be called
00055  * twice for the same lat, once as a south then again as a north
00056  */
00057 
00070 double G_area_for_zone_on_ellipsoid (
00071     register double north, register double south)
00072 {
00073     return (G_darea0_on_ellipsoid (north) - G_darea0_on_ellipsoid (south));
00074 }

Generated on Sat Jul 22 22:06:14 2006 for GRASS by  doxygen 1.4.7