GRASS Programmer's Manual
6.5.svn(2014)-r66266
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
gammavol.c
Go to the documentation of this file.
1
2
/****************************************************************************
3
* MODULE: R-Tree library
4
*
5
* AUTHOR(S): Antonin Guttman - original code
6
* Daniel Green (green@superliminal.com) - major clean-up
7
* and implementation of bounding spheres
8
*
9
* PURPOSE: Multidimensional index
10
*
11
* COPYRIGHT: (C) 2001 by the GRASS Development Team
12
*
13
* This program is free software under the GNU General Public
14
* License (>=v2). Read the file COPYING that comes with GRASS
15
* for details.
16
*****************************************************************************/
17
#include <stdio.h>
18
#include <math.h>
19
#include <grass/gis.h>
20
21
#ifndef ABS
22
# define ABS(a) ((a) > 0 ? (a) : -(a))
23
#endif
24
25
#define EP .0000000001
26
27
double
sphere_volume
(
double
dimension)
28
{
29
double
log_gamma, log_volume;
30
31
log_gamma = lgamma(dimension / 2.0 + 1);
32
log_volume = dimension / 2.0 *
log
(M_PI) - log_gamma;
33
return
exp(log_volume);
34
}
35
36
int
main
()
37
{
38
double
dim = 0, delta = 1;
39
40
while
(
ABS
(delta) >
EP
)
41
if
(
sphere_volume
(dim + delta) >
sphere_volume
(dim))
42
dim += delta;
43
else
44
delta /= -2;
45
fprintf(stdout,
"max volume = %.10f at dimension %.10f\n"
,
46
sphere_volume
(dim), dim);
47
return
0;
48
}
sphere_volume
double sphere_volume(double dimension)
Definition:
gammavol.c:27
wxnviz.log
log
Definition:
wxnviz.py:54
main
int main(int argc, char *argv[])
Definition:
gem/main.c:302
EP
#define EP
Definition:
gammavol.c:25
ABS
#define ABS(a)
Definition:
gammavol.c:22
lib
vector
rtree
gammavol.c
Generated on Sat Jan 2 2016 01:46:47 for GRASS Programmer's Manual by
1.8.5