Move and rework pow to math/SGMisc

This commit is contained in:
Thomas Geymayer
2013-04-28 15:43:02 +02:00
parent fa64f7b6aa
commit e53c71543a
2 changed files with 33 additions and 29 deletions
+16
View File
@@ -58,6 +58,22 @@ public:
return var = max(var - rate * dt, target);
}
/**
* Get @c base raised to the power of @c N
*
* @tparam N Exponent
* @param base Base
*/
template<int N>
static T pow(T base)
{
return (N < 0)
? (1. / pow<-N>(base))
: ( ((N & 1) ? base : 1)
* ((N > 1) ? pow<N / 2>(base * base) : 1)
);
}
static int sign(const T& a)
{
if (a < -SGLimits<T>::min())