X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fhyperbox.h;h=42e4d61a75a49ce0824aaf231388013246c1413f;hb=68389c29cf88d6522dcfa00b5e2a5166e3947210;hp=10c28d5d1f4c20a15937e7b0aa696f3074151aec;hpb=c135ff2480f4e2aaf05b0206631bb0e1b5d73fad;p=libs%2Fmath.git diff --git a/source/geometry/hyperbox.h b/source/geometry/hyperbox.h index 10c28d5..42e4d61 100644 --- a/source/geometry/hyperbox.h +++ b/source/geometry/hyperbox.h @@ -3,6 +3,7 @@ #include #include +#include #include #include "ray.h" #include "shape.h" @@ -47,7 +48,11 @@ inline HyperBox::HyperBox() template inline HyperBox::HyperBox(const LinAl::Vector &d): dimensions(d) -{ } +{ + for(unsigned i=0; i inline HyperBox *HyperBox::clone() const @@ -64,8 +69,10 @@ inline T HyperBox::get_dimension(unsigned i) const template inline bool HyperBox::contains(const LinAl::Vector &point) const { + using std::abs; + for(unsigned i=0; idimensions[i]/2) + if(abs(point[i])>dimensions[i]/T(2)) return false; return true; } @@ -91,7 +98,7 @@ inline unsigned HyperBox::get_intersections(const Ray &ray, SurfaceP for(int j=-1; j<=1; j+=2) { T x = (T(j)*half_dim[i]-ray.get_start()[i])/ray.get_direction()[i]; - if(x<0) + if(!ray.check_limits(x)) continue; LinAl::Vector p = ray.get_start()+ray.get_direction()*x;