| 1 |
/*
|
| 2 |
** Author: Christian Reetz ([email protected])
|
| 3 |
*/
|
| 4 |
#ifndef __GBASIC_H
|
| 5 |
#define __GBASIC_H
|
| 6 |
|
| 7 |
#ifdef __cplusplus
|
| 8 |
extern "C" {
|
| 9 |
#endif
|
| 10 |
|
| 11 |
|
| 12 |
#include <math.h>
|
| 13 |
|
| 14 |
#ifndef g3Float
|
| 15 |
#define g3Float double
|
| 16 |
#define USE_DOUBLE 1
|
| 17 |
#define GB_EPSILON 1e-6
|
| 18 |
#else
|
| 19 |
#define GB_EPSILON 1e-4
|
| 20 |
#endif
|
| 21 |
|
| 22 |
typedef unsigned char uchar;
|
| 23 |
|
| 24 |
#define DEG2RAD(x) ((x)*M_PI/180.0)
|
| 25 |
#define RAD2DEG(x) ((x)*180.0/M_PI)
|
| 26 |
|
| 27 |
#define GB_SWAP(a,b) {g3Float temp=(a);(a)=(b);(b)=temp;}
|
| 28 |
#define gb_swap(a,b) GB_SWAP(a,b)
|
| 29 |
|
| 30 |
#define gb_random() (((g3Float) rand())/(RAND_MAX-1))
|
| 31 |
|
| 32 |
int gb_epsorder(g3Float a,g3Float b);
|
| 33 |
|
| 34 |
int gb_epseq(g3Float a,g3Float b);
|
| 35 |
|
| 36 |
int gb_inrange(g3Float a,g3Float rb,g3Float re);
|
| 37 |
|
| 38 |
int gb_signum(g3Float a);
|
| 39 |
|
| 40 |
g3Float gb_max(g3Float a,g3Float b);
|
| 41 |
g3Float gb_min(g3Float a,g3Float b);
|
| 42 |
|
| 43 |
/* Roots of quadratic formula
|
| 44 |
Returns zero if roots are not real, 1 for single root and 2 otherwise
|
| 45 |
*/
|
| 46 |
int gb_getroots(g3Float* r1,g3Float* r2,g3Float a,g3Float b,g3Float c);
|
| 47 |
|
| 48 |
#ifdef __cplusplus
|
| 49 |
}
|
| 50 |
#endif
|
| 51 |
|
| 52 |
|
| 53 |
#endif
|