istereo
view libs/vmath/vmath.h @ 28:c0ae8e668447
added vmath library
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Thu, 08 Sep 2011 08:30:42 +0300 |
parents | |
children | ff055bff6a15 |
line source
1 #ifndef VMATH_H_
2 #define VMATH_H_
4 #include <math.h>
5 #include "vmath_types.h"
7 #ifndef M_PI
8 #define M_PI PI
9 #endif
11 #ifndef M_E
12 #define M_E 2.718281828459045
13 #endif
15 #define PI 3.141592653589793
16 #define HALF_PI 1.570796326794897
17 #define QUARTER_PI 0.785398163397448
18 #define TWO_PI 6.283185307179586
21 #define RAD_TO_DEG(a) ((((scalar_t)a) * 360.0) / TWO_PI)
22 #define DEG_TO_RAD(a) (((scalar_t)a) * (PI / 180.0))
24 #define SQ(x) ((x) * (x))
26 #define MIN(a, b) ((a) < (b) ? (a) : (b))
27 #define MAX(a, b) ((a) > (b) ? (a) : (b))
29 #ifndef __GNUC__
30 #define round(x) ((x) >= 0 ? (x) + 0.5 : (x) - 0.5)
31 #endif
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
37 static inline scalar_t frand(scalar_t range);
38 static inline vec3_t sphrand(scalar_t rad);
40 scalar_t integral(scalar_t (*f)(scalar_t), scalar_t low, scalar_t high, int samples);
41 scalar_t gaussian(scalar_t x, scalar_t mean, scalar_t sdev);
43 static inline scalar_t lerp(scalar_t a, scalar_t b, scalar_t t);
45 scalar_t bspline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
46 scalar_t spline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
47 scalar_t bezier(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
49 scalar_t noise1(scalar_t x);
50 scalar_t noise2(scalar_t x, scalar_t y);
51 scalar_t noise3(scalar_t x, scalar_t y, scalar_t z);
53 scalar_t fbm1(scalar_t x, int octaves);
54 scalar_t fbm2(scalar_t x, scalar_t y, int octaves);
55 scalar_t fbm3(scalar_t x, scalar_t y, scalar_t z, int octaves);
57 scalar_t turbulence1(scalar_t x, int octaves);
58 scalar_t turbulence2(scalar_t x, scalar_t y, int octaves);
59 scalar_t turbulence3(scalar_t x, scalar_t y, scalar_t z, int octaves);
61 #ifdef __cplusplus
62 }
63 #endif /* __cplusplus */
65 #include "vmath.inl"
67 #include "vector.h"
68 #include "matrix.h"
69 #include "quat.h"
70 #include "sphvec.h"
71 #include "ray.h"
72 #include "geom.h"
74 #endif /* VMATH_H_ */