istereo

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/vmath/vmath.h	Thu Sep 08 08:30:42 2011 +0300
     1.3 @@ -0,0 +1,74 @@
     1.4 +#ifndef VMATH_H_
     1.5 +#define VMATH_H_
     1.6 +
     1.7 +#include <math.h>
     1.8 +#include "vmath_types.h"
     1.9 +
    1.10 +#ifndef M_PI
    1.11 +#define M_PI	PI
    1.12 +#endif
    1.13 +
    1.14 +#ifndef M_E
    1.15 +#define M_E				2.718281828459045
    1.16 +#endif
    1.17 +
    1.18 +#define PI				3.141592653589793
    1.19 +#define HALF_PI			1.570796326794897
    1.20 +#define QUARTER_PI		0.785398163397448
    1.21 +#define TWO_PI			6.283185307179586
    1.22 +
    1.23 +
    1.24 +#define RAD_TO_DEG(a) ((((scalar_t)a) * 360.0) / TWO_PI)
    1.25 +#define DEG_TO_RAD(a) (((scalar_t)a) * (PI / 180.0))
    1.26 +
    1.27 +#define SQ(x) ((x) * (x))
    1.28 +
    1.29 +#define MIN(a, b)	((a) < (b) ? (a) : (b))
    1.30 +#define MAX(a, b)	((a) > (b) ? (a) : (b))
    1.31 +
    1.32 +#ifndef __GNUC__
    1.33 +#define round(x)	((x) >= 0 ? (x) + 0.5 : (x) - 0.5)
    1.34 +#endif
    1.35 +
    1.36 +#ifdef __cplusplus
    1.37 +extern "C" {
    1.38 +#endif	/* __cplusplus */
    1.39 +
    1.40 +static inline scalar_t frand(scalar_t range);
    1.41 +static inline vec3_t sphrand(scalar_t rad);
    1.42 +
    1.43 +scalar_t integral(scalar_t (*f)(scalar_t), scalar_t low, scalar_t high, int samples);
    1.44 +scalar_t gaussian(scalar_t x, scalar_t mean, scalar_t sdev);
    1.45 +
    1.46 +static inline scalar_t lerp(scalar_t a, scalar_t b, scalar_t t);
    1.47 +
    1.48 +scalar_t bspline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
    1.49 +scalar_t spline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
    1.50 +scalar_t bezier(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
    1.51 +
    1.52 +scalar_t noise1(scalar_t x);
    1.53 +scalar_t noise2(scalar_t x, scalar_t y);
    1.54 +scalar_t noise3(scalar_t x, scalar_t y, scalar_t z);
    1.55 +
    1.56 +scalar_t fbm1(scalar_t x, int octaves);
    1.57 +scalar_t fbm2(scalar_t x, scalar_t y, int octaves);
    1.58 +scalar_t fbm3(scalar_t x, scalar_t y, scalar_t z, int octaves);
    1.59 +
    1.60 +scalar_t turbulence1(scalar_t x, int octaves);
    1.61 +scalar_t turbulence2(scalar_t x, scalar_t y, int octaves);
    1.62 +scalar_t turbulence3(scalar_t x, scalar_t y, scalar_t z, int octaves);
    1.63 +
    1.64 +#ifdef __cplusplus
    1.65 +}
    1.66 +#endif	/* __cplusplus */
    1.67 +
    1.68 +#include "vmath.inl"
    1.69 +
    1.70 +#include "vector.h"
    1.71 +#include "matrix.h"
    1.72 +#include "quat.h"
    1.73 +#include "sphvec.h"
    1.74 +#include "ray.h"
    1.75 +#include "geom.h"
    1.76 +
    1.77 +#endif	/* VMATH_H_ */