Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-20 16:30:45 +0000
committerStijn Buys <ingar@osirion.org>2010-09-20 16:30:45 +0000
commite40f70a3af1142e6c0c89c6ea2ee47b996495661 (patch)
treeba70a909b5066ad0e07e2f4eb8bc98684e4598e6 /src/math
parente8f7c4a06fce9e41fb23ffc42a566501a78210cb (diff)
corrected trading inconsistencies, improved trade window, initial slider widget
Diffstat (limited to 'src/math')
-rw-r--r--src/math/functions.cc20
-rw-r--r--src/math/functions.h60
2 files changed, 52 insertions, 28 deletions
diff --git a/src/math/functions.cc b/src/math/functions.cc
index 7fb40be..7c95a79 100644
--- a/src/math/functions.cc
+++ b/src/math/functions.cc
@@ -12,26 +12,6 @@ namespace math
const float DELTA = 10e-10;
-float min(float a, float b)
-{
- return (a < b ? a : b);
-}
-
-float max(float a, float b)
-{
- return (a > b ? a : b);
-}
-
-int min(int a, int b)
-{
- return (a < b ? a : b);
-}
-
-int max(int a, int b)
-{
- return (a > b ? a : b);
-}
-
float randomf(const float max)
{
return ((float) rand() / (float) RAND_MAX) * max;
diff --git a/src/math/functions.h b/src/math/functions.h
index 5a53d44..8135392 100644
--- a/src/math/functions.h
+++ b/src/math/functions.h
@@ -15,17 +15,53 @@
namespace math
{
-/// return the smallest of two float values
-float min(float a, float b);
+/**
+ * @brief return the smallest of two floats
+ */
+inline const float min(const float a, const float b)
+{
+ return (a < b ? a : b);
+}
-/// return the smallest of two integers
-int min(int a, int b);
+/**
+ * @brief return the smallest of two integers
+ */
+inline const int min(const int a, const int b)
+{
+ return (a < b ? a : b);
+}
-/// return the largest of two float values
-float max(float a, float b);
+/**
+ * @brief return the smallest of two longs
+ */
+inline const long min(const long a, const long b)
+{
+ return (a < b ? a : b);
+}
-/// return the largest of two integers
-int max(int a, int b);
+/**
+ * @brief return the largest of two floats
+ */
+inline const float max(const float a, const float b)
+{
+ return (a > b ? a : b);
+}
+
+/**
+ * @brief return the largest of two integers
+ */
+inline const int max(const int a, const int b)
+{
+ return (a > b ? a : b);
+}
+
+/**
+ * @brief return the largest of two longs
+ */
+inline const long max(const long a, const long b)
+{
+ return (a > b ? a : b);
+}
/// returns a random float
/** The value returned will be in the interval [0-max]
@@ -63,6 +99,14 @@ inline float absf(const float f)
return ( f < 0.0f ? -f : f );
}
+/// swap two float values
+inline void swap(float &x, float &y)
+{
+ float tmp = x;
+ x = y;
+ y = tmp;
+}
+
} // namespace math
#endif // __INCLUDED_MATH_FUNCTIONS_H__