]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGMisc.hxx
canvas::Text: get maximum width (if displayed on a single line).
[simgear.git] / simgear / math / SGMisc.hxx
index 90f9c663e6638323a4209718614c7f110be97c48..0f57edf17713d8cef1a9fb9c181acb5591366b48 100644 (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())