Loading...
Searching...
No Matches
area_sphere.c
Go to the documentation of this file.
/*!
* \file lib/gis/area_sphere.c
*
* \brief GIS Library - Sphereical area calculation routines.
*
* (C) 2001-2009 by the GRASS Development Team
*
* This program is free software under the GNU General Public License
* (>=v2). Read the file COPYING that comes with GRASS for details.
*
* \author Original author CERL
*/
#include <math.h>
#include <grass/gis.h>
#include "pi.h"
static struct state {
double M;
} state;
static struct state *st = &state;
/*!
* \brief Initialize calculations for sphere.
*
* Initializes raster area calculations for a sphere.
* The radius of the sphere is <i>r</i> and <i>s</i> is a scale factor to
* allow for calculations of a part of the zone (see
* G_begin_zone_area_on_ellipsoid()).
*
* \param r radius of sphere
* \param s scale factor
*/
void G_begin_zone_area_on_sphere(double r, double s)
{
st->M = s * 2.0 * r * r * M_PI;
}
/*!
* \brief Calculates integral for area between two latitudes.
*
* \param lat latitude
*
* \return area value
*/
double G_darea0_on_sphere(double lat)
{
return (st->M * sin(Radians(lat)));
}
/*!
* \brief Calculates area between latitudes.
*
* This routine shows how to calculate area between two lats, but
* isn't efficient for row by row since G_darea0_on_sphere() will
* be called twice for the same lat, once as a <i>south</i> then
* again as a <i>north</i>.
*
* Returns the area between latitudes <i>north</i> and <i>south</i>
* scaled by the factor <i>s</i> passed to
* G_begin_zone_area_on_sphere().
*
* \param north
* \param[in] south
* \return double
*/
double G_area_for_zone_on_sphere(double north, double south)
{
return (G_darea0_on_sphere(north) - G_darea0_on_sphere(south));
}
G_begin_zone_area_on_sphere
void G_begin_zone_area_on_sphere(double r, double s)
Initialize calculations for sphere.
Definition area_sphere.c:35
G_darea0_on_sphere
double G_darea0_on_sphere(double lat)
Calculates integral for area between two latitudes.
Definition area_sphere.c:47
G_area_for_zone_on_sphere
double G_area_for_zone_on_sphere(double north, double south)
Calculates area between latitudes.
Definition area_sphere.c:68
r
double r
Definition driver/set_window.c:5
pi.h
Radians
#define Radians(x)
Definition pi.h:6