Changeset 845 for code/branches/core/src/util/Math.h
- Timestamp:
- Mar 1, 2008, 9:29:23 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/util/Math.h
r792 r845 59 59 60 60 template <typename T> 61 inline _UtilExportT sgn(T x)61 inline T sgn(T x) 62 62 { 63 63 return (x >= 0) ? 1 : -1; … … 65 65 66 66 template <typename T> 67 inline _UtilExportT min(T a, T b)67 inline T min(T a, T b) 68 68 { 69 69 return (a <= b) ? a : b; … … 71 71 72 72 template <typename T> 73 inline _UtilExportT max(T a, T b)73 inline T max(T a, T b) 74 74 { 75 75 return (a >= b) ? a : b; … … 77 77 78 78 template <typename T> 79 inline _UtilExportT clamp(T x, T min, T max)79 inline T clamp(T x, T min, T max) 80 80 { 81 81 if (x < min) … … 89 89 90 90 template <typename T> 91 inline _UtilExportT square(T x)91 inline T square(T x) 92 92 { 93 93 return x*x; … … 95 95 96 96 template <typename T> 97 inline _UtilExportT cube(T x)97 inline T cube(T x) 98 98 { 99 99 return x*x*x; … … 101 101 102 102 template <typename T> 103 inline _UtilExportint floor(T x)103 inline int floor(T x) 104 104 { 105 105 return (int)(x); … … 107 107 108 108 template <typename T> 109 inline _UtilExportint ceil(T x)109 inline int ceil(T x) 110 110 { 111 111 int temp = floor(x); … … 114 114 115 115 template <typename T> 116 inline _UtilExportint round(T x)116 inline int round(T x) 117 117 { 118 118 return (int)(x + 0.5); … … 120 120 121 121 template <typename T> 122 _UtilExportT interpolate(float time, const T& start, const T& end)122 T interpolate(float time, const T& start, const T& end) 123 123 { 124 124 return time * (end - start) + start; … … 126 126 127 127 template <typename T> 128 _UtilExportT interpolateSmooth(float time, const T& start, const T& end)128 T interpolateSmooth(float time, const T& start, const T& end) 129 129 { 130 130 return (-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start;
Note: See TracChangeset
for help on using the changeset viewer.