istereo

annotate libs/vmath/vmath.h @ 33:33e9eedad390

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