gpuray_glsl

view vmath/vmath.h @ 3:297dbc5080c4

cone intersection
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 09 Nov 2014 20:13:33 +0200
parents f234630e38ff
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 #define MIN(a, b) ((a) < (b) ? (a) : (b))
45 #define MAX(a, b) ((a) > (b) ? (a) : (b))
47 #ifdef __cplusplus
48 extern "C" {
49 #endif /* __cplusplus */
51 static inline scalar_t smoothstep(float a, float b, float x);
53 static inline scalar_t frand(scalar_t range);
54 static inline vec3_t sphrand(scalar_t rad);
56 scalar_t integral(scalar_t (*f)(scalar_t), scalar_t low, scalar_t high, int samples);
57 scalar_t gaussian(scalar_t x, scalar_t mean, scalar_t sdev);
59 static inline scalar_t lerp(scalar_t a, scalar_t b, scalar_t t);
61 scalar_t bspline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
62 scalar_t spline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
63 scalar_t bezier(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
65 scalar_t noise1(scalar_t x);
66 scalar_t noise2(scalar_t x, scalar_t y);
67 scalar_t noise3(scalar_t x, scalar_t y, scalar_t z);
69 scalar_t fbm1(scalar_t x, int octaves);
70 scalar_t fbm2(scalar_t x, scalar_t y, int octaves);
71 scalar_t fbm3(scalar_t x, scalar_t y, scalar_t z, int octaves);
73 scalar_t turbulence1(scalar_t x, int octaves);
74 scalar_t turbulence2(scalar_t x, scalar_t y, int octaves);
75 scalar_t turbulence3(scalar_t x, scalar_t y, scalar_t z, int octaves);
77 #ifdef __cplusplus
78 }
79 #endif /* __cplusplus */
81 #include "vmath.inl"
83 #include "vector.h"
84 #include "matrix.h"
85 #include "quat.h"
86 #include "ray.h"
88 #endif /* VMATH_H_ */