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