]> git.tdb.fi Git - libs/math.git/blobdiff - source/geometry/hyperbox.h
Verify that parameters make sense
[libs/math.git] / source / geometry / hyperbox.h
index 865b968902f078b25297138786f3602fbafa9260..0e4efd81995508de416d37cffd6ad12e3bbf2184 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <algorithm>
 #include <cmath>
+#include <stdexcept>
 #include <msp/linal/vector.h>
 #include "ray.h"
 #include "shape.h"
@@ -47,7 +48,11 @@ inline HyperBox<T, D>::HyperBox()
 template<typename T, unsigned D>
 inline HyperBox<T, D>::HyperBox(const LinAl::Vector<T, D> &d):
        dimensions(d)
-{ }
+{
+       for(unsigned i=0; i<D; ++i)
+               if(dimensions[i]<=T(0))
+                       throw std::invalid_argument("HyperBox::HyperBox");
+}
 
 template<typename T, unsigned D>
 inline HyperBox<T, D> *HyperBox<T, D>::clone() const