]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGVec4.hxx
use the proper namespace
[simgear.git] / simgear / math / SGVec4.hxx
index 6e42d957d8710f9a3a56c85cfa9d0b3ddf41f0bd..4339dfd9b79879a3fab0da2b59a5cca747cc5578 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef SGVec4_H
 #define SGVec4_H
 
+#include <iosfwd>
+
 /// 4D Vector Class
 template<typename T>
 class SGVec4 {
@@ -242,6 +244,19 @@ max(S s, const SGVec4<T>& v)
                    SGMisc<T>::max(s, v(3)));
 }
 
+/// Add two vectors taking care of (integer) overflows. The values are limited
+/// to the respective minimum and maximum values.
+template<class T>
+SGVec4<T> addClipOverflow(SGVec4<T> const& lhs, SGVec4<T> const& rhs)
+{
+  return SGVec4<T>(
+    SGMisc<T>::addClipOverflow(lhs.x(), rhs.x()),
+    SGMisc<T>::addClipOverflow(lhs.y(), rhs.y()),
+    SGMisc<T>::addClipOverflow(lhs.z(), rhs.z()),
+    SGMisc<T>::addClipOverflow(lhs.w(), rhs.w())
+  );
+}
+
 /// Scalar dot product
 template<typename T>
 inline