X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fray.h;h=6c9a65bf4785c38ae07ab6fc78e4a4337575200b;hb=fb9e6b5ff48e10ea2217cf539e0461956abf02cf;hp=4825cfe005d3c6cc762dae62800f38899f8c8500;hpb=6ff13022b53830d35283905d562c2ef3af198cc1;p=libs%2Fmath.git diff --git a/source/geometry/ray.h b/source/geometry/ray.h index 4825cfe..6c9a65b 100644 --- a/source/geometry/ray.h +++ b/source/geometry/ray.h @@ -1,6 +1,7 @@ #ifndef MSP_GEOMETRY_RAY_H_ #define MSP_GEOMETRY_RAY_H_ +#include #include namespace Msp { @@ -12,27 +13,49 @@ class Ray private: LinAl::Vector start; LinAl::Vector direction; + T limit; public: Ray(); Ray(const LinAl::Vector &, const LinAl::Vector &); + Ray(const LinAl::Vector &, const LinAl::Vector &, T); const LinAl::Vector &get_start() const { return start; } const LinAl::Vector &get_direction() const { return direction; } + T get_limit() const { return limit; } + bool check_limits(T) const; }; template -Ray::Ray() +inline Ray::Ray(): + limit(0) { - direction[0] = 1; + direction[0] = T(1); } template -Ray::Ray(const LinAl::Vector &s, const LinAl::Vector &d): +inline Ray::Ray(const LinAl::Vector &s, const LinAl::Vector &d): start(s), - direction(normalize(d)) + direction(normalize(d)), + limit(0) { } +template +inline Ray::Ray(const LinAl::Vector &s, const LinAl::Vector &d, T l): + start(s), + direction(normalize(d)), + limit(l) +{ + if(l +inline bool Ray::check_limits(T x) const +{ + return x>=T(0) && (!limit || x<=limit); +} + } // namespace Geometry } // namespace Msp