sphere: check radius is positive at construction

This commit is contained in:
Danny Robson 2015-04-15 14:29:43 +10:00
parent 3decd9e0ab
commit ed38fd0491
2 changed files with 13 additions and 0 deletions

View File

@ -19,4 +19,14 @@
using util::sphere; using util::sphere;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <size_t S, typename T>
sphere<S,T>::sphere (point<S,T> _centre, T _radius):
centre (_centre),
radius (_radius)
{
CHECK_GE (_radius, 0);
}
//-----------------------------------------------------------------------------
template struct util::sphere<2,float>;
template struct util::sphere<3,float>; template struct util::sphere<3,float>;

View File

@ -22,10 +22,13 @@
namespace util { namespace util {
template <size_t S, typename T> template <size_t S, typename T>
struct sphere { struct sphere {
sphere (point<S,T> centre, T radius);
point<S,T> centre; point<S,T> centre;
T radius; T radius;
}; };
typedef sphere<2,float> sphere2f;
typedef sphere<3,float> sphere3f; typedef sphere<3,float> sphere3f;
} }