Mercurial > fife-parpg
comparison engine/core/util/math/math.i @ 646:07b1cf8e92b5
* Major improvements to fife_math.h and added corresponding Python bindings. Users now have access to FIFE's internal math functions. These functions are recommended to be used by all clients if required. Note: this may cause some problems with certain compilers. I hope this wont have to be reverted. TODO: remove the static constant globals somehow.
* Adopted the new math functions for all subsystems
* Improvements to DeviceCaps. It now detects all possible screen modes.
* User can now select 0 for their bpp and it will attempt to initialize SDL with the current screen bpp.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 13 Oct 2010 20:24:48 +0000 |
parents | 684e5537eef7 |
children |
comparison
equal
deleted
inserted
replaced
645:291ba2946c73 | 646:07b1cf8e92b5 |
---|---|
24 #include "util/math/fife_math.h" | 24 #include "util/math/fife_math.h" |
25 %} | 25 %} |
26 | 26 |
27 namespace FIFE { | 27 namespace FIFE { |
28 | 28 |
29 static const float FLT_ZERO_TOLERANCE; | 29 template <class numT> |
30 static const float FLT_PI; | 30 struct float_traits { }; |
31 static const float FLT_TWO_PI; | |
32 static const float FLT_HALF_PI; | |
33 static const float FLT_INVERSE_PI; | |
34 static const float FLT_INVERSE_TWO_PI; | |
35 static const float FLT_DEG_TO_RAD; | |
36 static const float FLT_RAD_TO_DEG; | |
37 static const float FLT_LOG_2; | |
38 static const float FLT_LOG_10; | |
39 static const float FLT_INV_LOG_2; | |
40 static const float FLT_INV_LOG_10; | |
41 | 31 |
42 static const double DBL_ZERO_TOLERANCE; | 32 template <typename T> |
43 static const double DBL_PI; | 33 class Math { |
44 static const double DBL_TWO_PI; | 34 public: |
45 static const double DBL_HALF_PI; | 35 typedef T num_type; |
46 static const double DBL_INVERSE_PI; | 36 typedef float_traits<num_type> traits_type; |
47 static const double DBL_INVERSE_TWO_PI; | 37 |
48 static const double DBL_DEG_TO_RAD; | 38 static inline num_type epsilon(); |
49 static const double DBL_RAD_TO_DEG; | 39 static inline num_type zeroTolerance(); |
50 static const double DBL_LOG_2; | 40 static inline num_type max(); |
51 static const double DBL_LOG_10; | 41 static inline num_type pi(); |
52 static const double DBL_INV_LOG_2; | 42 static inline num_type twoPi(); |
53 static const double DBL_INV_LOG_10; | 43 static inline num_type halfPi(); |
44 static inline num_type inversePi(); | |
45 static inline num_type inverseTwoPi(); | |
46 static inline num_type degToRad(); | |
47 static inline num_type radToDeg(); | |
48 static inline num_type log2(); | |
49 static inline num_type log10(); | |
50 static inline num_type invLog2(); | |
51 static inline num_type invLog10(); | |
52 | |
53 static T ACos(T _val); | |
54 static T ASin(T _val); | |
55 static T ATan(T _val); | |
56 static T ATan2(T _x, T _y); | |
57 static T Ceil(T _val); | |
58 static T Cos(T _val); | |
59 static T Exp(T _val); | |
60 static T FAbs(T _val); | |
61 static T Floor(T _val); | |
62 static T FMod (T _x, T _y); | |
63 static T InvSqrt(T _val); | |
64 static T Log(T _val); | |
65 static T Log2(T _val); | |
66 static T Log10(T _val); | |
67 static T Pow(T _base, T _exponent); | |
68 static T Sin(T _val); | |
69 static T Sqr(T _val); | |
70 static T Sqrt(T _val); | |
71 static T Tan(T _val); | |
72 }; | |
73 | |
74 typedef Math<float> Mathf; | |
75 typedef Math<double> Mathd; | |
76 | |
77 %template(Mathf) Math<float>; | |
78 %template(Mathd) Math<double>; | |
54 | 79 |
55 } | 80 } |