From 61bfb22f27f5216f989c023a5e39fad7e356d2d6 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Fri, 3 Aug 2012 23:23:13 +0200 Subject: Basic font rendering - added basic font rendering - minor refactoring & fixes --- src/math/func.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/math/func.h') diff --git a/src/math/func.h b/src/math/func.h index 2127d1a..e97d990 100644 --- a/src/math/func.h +++ b/src/math/func.h @@ -127,6 +127,14 @@ inline float Rand() return static_cast(rand()) / static_cast(RAND_MAX); } +//! Returns the next nearest power of two to \a x +inline int NextPowerOfTwo(int x) +{ + double logbase2 = log(static_cast(x)) / Math::LOG_2; + return static_cast(pow(2, ceil(logbase2)) + 0.5); +} + + //! Returns a normalized angle, that is in other words between 0 and 2 * PI inline float NormAngle(float angle) { -- cgit v1.2.3-1-g7c22 From 1996507fd3d4d9de90de99845b71a6bf3fbe62da Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 11 Aug 2012 18:39:16 +0200 Subject: Documentation update - updated Doxyfile - added/changed file, dir and namespace descriptions - fixed some errors in doxygen tags --- src/math/func.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/math/func.h') diff --git a/src/math/func.h b/src/math/func.h index e97d990..541b084 100644 --- a/src/math/func.h +++ b/src/math/func.h @@ -15,8 +15,9 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -/** @defgroup MathFuncModule math/func.h - Contains common math functions. +/** + * \file math/func.h + * \brief Common math functions */ #pragma once @@ -31,8 +32,6 @@ namespace Math { -/* @{ */ // start of group - //! Compares \a a and \a b within \a tolerance inline bool IsEqual(float a, float b, float tolerance = Math::TOLERANCE) { @@ -188,11 +187,13 @@ inline float Direction(float a, float g) //! Managing the dead zone of a joystick. /** -\verbatimin: -1 0 1 +\verbatim +in: -1 0 1 --|-------|----o----|-------|--> <----> dead -out: -1 0 0 1\endverbatim */ +out: -1 0 0 1 +\endverbatim */ inline float Neutral(float value, float dead) { if ( fabs(value) <= dead ) @@ -226,7 +227,8 @@ inline float Smooth(float actual, float hope, float time) //! Bounces any movement /** -\verbatimout +\verbatim +out | 1+------o-------o--- | o | o o | | bounce @@ -235,7 +237,8 @@ inline float Smooth(float actual, float hope, float time) | o | | -o------|-------+----> progress 0| | 1 - |<---->|middle\endverbatim */ + |<---->|middle +\endverbatim */ inline float Bounce(float progress, float middle = 0.3f, float bounce = 0.4f) { if ( progress < middle ) @@ -250,6 +253,4 @@ inline float Bounce(float progress, float middle = 0.3f, float bounce = 0.4f) } } -/* @} */ // end of group - }; // namespace Math -- cgit v1.2.3-1-g7c22