diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-08-19 17:10:03 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-10-25 11:03:56 -0400 |
commit | 7b09710392d35fb55b52031d447a542d99fc6b4b (patch) | |
tree | 270eb927ee8c52ceeb99926ebf4843704775a610 /libdimension/dimension/math.h | |
parent | 200c86b91ea7063d35be3bffc11c5da53c054653 (diff) | |
download | dimension-7b09710392d35fb55b52031d447a542d99fc6b4b.tar.xz |
Modularize the libdimension codebase.
Diffstat (limited to 'libdimension/dimension/math.h')
-rw-r--r-- | libdimension/dimension/math.h | 82 |
1 files changed, 14 insertions, 68 deletions
diff --git a/libdimension/dimension/math.h b/libdimension/dimension/math.h index 597be36..603373f 100644 --- a/libdimension/dimension/math.h +++ b/libdimension/dimension/math.h @@ -20,80 +20,26 @@ /** * @file - * Useful math functions. + * Mathematical functions and types. */ -#include <math.h> -#include <stdbool.h> +#ifndef DMNSN_MATH_H +#define DMNSN_MATH_H -/** The smallest value considered non-zero by some numerical algorithms. */ -#define dmnsn_epsilon 1.0e-10 - -/** - * @def DMNSN_INFINITY - * Expands to floating-point infinity. - */ -#if defined(INFINITY) || DMNSN_C99 - #define DMNSN_INFINITY INFINITY -#else - #define DMNSN_INFINITY HUGE_VAL +#ifdef __cplusplus +extern "C" { #endif -/** Find the minimum of two values. */ -DMNSN_INLINE double -dmnsn_min(double a, double b) -{ - return a < b ? a : b; -} - -/** Find the maximum of two values. */ -DMNSN_INLINE double -dmnsn_max(double a, double b) -{ - return a > b ? a : b; -} - -/** Clamp a value to an interval. */ -DMNSN_INLINE double -dmnsn_clamp(double n, double min, double max) -{ - return dmnsn_min(dmnsn_max(n, min), max); -} - -/** Convert degrees to radians. */ -DMNSN_INLINE double -dmnsn_radians(double degrees) -{ - return degrees*(atan(1.0)/45.0); -} +#include <dimension/base.h> -/** Convert radians to degrees. */ -DMNSN_INLINE double -dmnsn_degrees(double radians) -{ - return radians*(45.0/atan(1.0)); -} +#include <dimension/math/scalar.h> +#include <dimension/math/vector.h> +#include <dimension/math/ray.h> +#include <dimension/math/aabb.h> +#include <dimension/math/matrix.h> -/** Signum function: return the sign of a value. */ -DMNSN_INLINE int -dmnsn_sgn(double n) -{ - if (n > 0.0) { - return 1; - } else if (n < 0.0) { - return -1; - } else { - return 0; - } +#ifdef __cplusplus } - -/** Return whether a value is NaN. */ -DMNSN_INLINE bool -dmnsn_isnan(double n) -{ -#if DMNSN_C99 - return isnan(n); -#else - return n != n; #endif -} + +#endif /* DMNSN_MATH_H */ |