3dphotoshoot

annotate libs/vmath/vmath.h @ 15:2d48f65da357

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