Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-01-30 17:30:10 +0000
committerStijn Buys <ingar@osirion.org>2008-01-30 17:30:10 +0000
commit4fd8d5c71365e58e6dff36fc756d8e2e55204db7 (patch)
tree851c86f497ce3bfa7050ae5634f50f888d6d80f8 /src/math/functions.h
parent28180e6b6763e4ce5d65c02e4df5380f11e6d10a (diff)
math module
Diffstat (limited to 'src/math/functions.h')
-rw-r--r--src/math/functions.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/math/functions.h b/src/math/functions.h
new file mode 100644
index 0000000..767af2d
--- /dev/null
+++ b/src/math/functions.h
@@ -0,0 +1,52 @@
+/*
+ math/functions.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_MATH_FUNCTIONS_H__
+#define __INCLUDED_MATH_FUNCTIONS_H__
+
+// C++ headers
+#include <cstdlib>
+#include <cmath>
+
+namespace math {
+
+/// return the smallest of two float values
+float min(float a, float b);
+
+/// return the smallest of two integers
+int min(int a, int b);
+
+/// return the largest of two float values
+float max(float a, float b);
+
+/// return the largest of two integers
+int max(int a, int b);
+
+/// returns a random float
+/** The value returned will be in the interval [0-max]
+ * @param max the maximum value returned
+ **/
+float randomf(const float max = 1);
+
+/// returns a random integer
+/** The value returned will be in the interval [0-(max-1)]
+ * @param max the maximum value returned
+ **/
+unsigned int randomi(const unsigned int max);
+
+/// return the sign of a float value
+float sgnf(float value);
+
+/// return an angle in the ]-180,180] range
+float degrees180f(float angle);
+
+/// return an angle in the [0,360[ range
+float degrees360f(float angle);
+
+} // namespace math
+
+#endif // __INCLUDED_MATH_FUNCTIONS_H__
+