dungeon_crawler

annotate prototype/vmath/vmath.h @ 67:2560a7ab0243

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