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