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