… | |
… | |
14 | # define NOTHROW throw() |
14 | # define NOTHROW throw() |
15 | # define THROW(x) throw x |
15 | # define THROW(x) throw x |
16 | #endif |
16 | #endif |
17 | |
17 | |
18 | // various utility functions |
18 | // various utility functions |
19 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
19 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
20 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
20 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
21 | |
21 | |
22 | template<typename T, typename U, typename V> static inline T clamp (T v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; } |
22 | template<typename T, typename U, typename V> static inline T clamp (T v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; } |
23 | template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = v < (T)a ? a : v >(T)b ? b : v; } |
23 | template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = v < (T)a ? a : v >(T)b ? b : v; } |
24 | |
24 | |
25 | template<typename T> static inline T squared_diff (T a, T b) { return (a-b)*(a-b); } |
25 | template<typename T> static inline T squared_diff (T a, T b) { return (a - b) * (a - b); } |
26 | |
26 | |
27 | // linear interpolation |
27 | // linear interpolation |
28 | template<typename T, typename U, typename P> |
28 | template<typename T, typename U, typename P> |
29 | static inline |
29 | static inline |
30 | T lerp (T a, U b, P p) |
30 | T lerp (T a, U b, P p) |