area_sphere.c

Go to the documentation of this file.
00001 #include <math.h>
00002 #include <grass/gis.h>
00003 #include "pi.h"
00004 
00005 static double M;
00006 
00007 /*
00008  * r is radius of sphere, s is a scaling factor
00009  */
00010 
00024 int G_begin_zone_area_on_sphere (double r,double s)
00025 {
00026     return (M = s * 2.0 * r * r * PI);
00027 }
00028 
00029 /*
00030  * part of integral for area between two latitudes
00031  */
00032 double G_darea0_on_sphere ( register double lat)
00033 {
00034     return ( M * sin (Radians(lat)) );
00035 }
00036 
00037 /*
00038  * this routine shows how to calculate area between two lats, but
00039  * isn't efficient for row by row since G_darea0() will be called
00040  * twice for the same lat, once as a south then again as a north
00041  */
00042 
00055 double G_area_for_zone_on_sphere (
00056     register double north,
00057     register double south)
00058 {
00059     return (G_darea0_on_sphere(north) - G_darea0_on_sphere(south));
00060 }

Generated on Fri Nov 21 11:02:17 2008 for GRASS by  doxygen 1.5.1