3dphotoshoot

view libs/vmath/vmath.h @ 13:8cfe061ddd5f

fixed the assets directories in the android makefile
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 07 Jun 2015 02:29:10 +0300
parents
children
line source
1 /*
2 libvmath - a vector math library
3 Copyright (C) 2004-2015 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
19 #ifndef VMATH_H_
20 #define VMATH_H_
22 #include <math.h>
23 #include "vmath_types.h"
25 #ifndef M_PI
26 #define M_PI PI
27 #endif
29 #ifndef M_E
30 #define M_E 2.718281828459045
31 #endif
33 #define PI 3.141592653589793
34 #define HALF_PI 1.570796326794897
35 #define QUARTER_PI 0.785398163397448
36 #define TWO_PI 6.283185307179586
39 #define RAD_TO_DEG(a) ((((scalar_t)a) * 360.0) / TWO_PI)
40 #define DEG_TO_RAD(a) (((scalar_t)a) * (PI / 180.0))
42 #define SQ(x) ((x) * (x))
44 #define MIN(a, b) ((a) < (b) ? (a) : (b))
45 #define MAX(a, b) ((a) > (b) ? (a) : (b))
47 #if (__STDC_VERSION__ < 199901L) && (__cplusplus < 201103L) && !defined(__GNUC__) && (_MSC_VER < 1800)
48 #define round(x) ((x) >= 0 ? (x) + 0.5 : (x) - 0.5)
49 #endif
51 #ifdef __cplusplus
52 extern "C" {
53 #endif /* __cplusplus */
55 void enable_fpexcept(void);
56 void disable_fpexcept(void);
58 static inline scalar_t smoothstep(float a, float b, float x);
60 static inline scalar_t frand(scalar_t range);
61 static inline vec3_t sphrand(scalar_t rad);
63 scalar_t integral(scalar_t (*f)(scalar_t), scalar_t low, scalar_t high, int samples);
64 scalar_t gaussian(scalar_t x, scalar_t mean, scalar_t sdev);
66 static inline scalar_t lerp(scalar_t a, scalar_t b, scalar_t t);
68 scalar_t bspline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
69 scalar_t spline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
70 scalar_t bezier(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
72 scalar_t noise1(scalar_t x);
73 scalar_t noise2(scalar_t x, scalar_t y);
74 scalar_t noise3(scalar_t x, scalar_t y, scalar_t z);
76 scalar_t fbm1(scalar_t x, int octaves);
77 scalar_t fbm2(scalar_t x, scalar_t y, int octaves);
78 scalar_t fbm3(scalar_t x, scalar_t y, scalar_t z, int octaves);
80 scalar_t turbulence1(scalar_t x, int octaves);
81 scalar_t turbulence2(scalar_t x, scalar_t y, int octaves);
82 scalar_t turbulence3(scalar_t x, scalar_t y, scalar_t z, int octaves);
84 #ifdef __cplusplus
85 }
86 #endif /* __cplusplus */
88 #include "vmath.inl"
90 #include "vector.h"
91 #include "matrix.h"
92 #include "quat.h"
93 #include "sphvec.h"
94 #include "ray.h"
95 #include "geom.h"
97 #endif /* VMATH_H_ */