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