]> git.tdb.fi Git - libs/math.git/blobdiff - source/geometry/hypersphere.h
Verify that parameters make sense
[libs/math.git] / source / geometry / hypersphere.h
index 01aee0e57b22e2791763077aecb3e3193ea35843..de028fa580d627ed06d1cb811f43b104a450ed7a 100644 (file)
@@ -2,6 +2,7 @@
 #define MSP_GEOMETRY_HYPERSPHERE_H_
 
 #include <cmath>
+#include <stdexcept>
 #include <msp/linal/vector.h>
 #include "hyperbox.h"
 #include "ray.h"
@@ -44,7 +45,10 @@ inline HyperSphere<T, D>::HyperSphere():
 template<typename T, unsigned D>
 inline HyperSphere<T, D>::HyperSphere(T r):
        radius(r)
-{ }
+{
+       if(r<=T(0))
+               throw std::invalid_argument("HyperSphere::HyperShpere");
+}
 
 template<typename T, unsigned D>
 inline HyperSphere<T, D> *HyperSphere<T, D>::clone() const