dbf-halloween2015

view libs/vmath/vmath.h @ 3:c37fe5d8a4ed

windows port
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 01 Nov 2015 06:04:28 +0200
parents c3f5c32cb210
children
line source
1 /*
2 libvmath - a vector math library
3 Copyright (C) 2004-2013 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 #ifndef MIN
45 #define MIN(a, b) ((a) < (b) ? (a) : (b))
46 #endif
47 #ifndef MAX
48 #define MAX(a, b) ((a) > (b) ? (a) : (b))
49 #endif
51 #if !defined(__GNUC__) && (!defined(_MSC_VER) || _MSC_VER < 1800)
52 #define round(x) ((x) >= 0 ? (x) + 0.5 : (x) - 0.5)
53 #endif
55 #ifdef __cplusplus
56 extern "C" {
57 #endif /* __cplusplus */
59 void enable_fpexcept(void);
60 void disable_fpexcept(void);
62 static inline scalar_t smoothstep(float a, float b, float x);
64 static inline scalar_t frand(scalar_t range);
65 static inline vec3_t sphrand(scalar_t rad);
67 scalar_t integral(scalar_t (*f)(scalar_t), scalar_t low, scalar_t high, int samples);
68 scalar_t gaussian(scalar_t x, scalar_t mean, scalar_t sdev);
70 static inline scalar_t lerp(scalar_t a, scalar_t b, scalar_t t);
72 scalar_t bspline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
73 scalar_t spline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
74 scalar_t bezier(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
76 scalar_t noise1(scalar_t x);
77 scalar_t noise2(scalar_t x, scalar_t y);
78 scalar_t noise3(scalar_t x, scalar_t y, scalar_t z);
80 scalar_t fbm1(scalar_t x, int octaves);
81 scalar_t fbm2(scalar_t x, scalar_t y, int octaves);
82 scalar_t fbm3(scalar_t x, scalar_t y, scalar_t z, int octaves);
84 scalar_t turbulence1(scalar_t x, int octaves);
85 scalar_t turbulence2(scalar_t x, scalar_t y, int octaves);
86 scalar_t turbulence3(scalar_t x, scalar_t y, scalar_t z, int octaves);
88 #ifdef __cplusplus
89 }
90 #endif /* __cplusplus */
92 #include "vmath.inl"
94 #include "vector.h"
95 #include "matrix.h"
96 #include "quat.h"
97 #include "sphvec.h"
98 #include "ray.h"
99 #include "geom.h"
101 #endif /* VMATH_H_ */