1 #ifndef MSP_GEOMETRY_RAY_H_
2 #define MSP_GEOMETRY_RAY_H_
5 #include <msp/linal/vector.h>
10 template<typename T, unsigned D>
14 LinAl::Vector<T, D> start;
15 LinAl::Vector<T, D> direction;
20 Ray(const LinAl::Vector<T, D> &, const LinAl::Vector<T, D> &);
21 Ray(const LinAl::Vector<T, D> &, const LinAl::Vector<T, D> &, T);
23 const LinAl::Vector<T, D> &get_start() const { return start; }
24 const LinAl::Vector<T, D> &get_direction() const { return direction; }
25 T get_limit() const { return limit; }
26 bool check_limits(T) const;
29 template<typename T, unsigned D>
30 inline Ray<T, D>::Ray():
36 template<typename T, unsigned D>
37 inline Ray<T, D>::Ray(const LinAl::Vector<T, D> &s, const LinAl::Vector<T, D> &d):
39 direction(normalize(d)),
43 template<typename T, unsigned D>
44 inline Ray<T, D>::Ray(const LinAl::Vector<T, D> &s, const LinAl::Vector<T, D> &d, T l):
46 direction(normalize(d)),
50 throw std::invalid_argument("Ray::Ray");
53 template<typename T, unsigned D>
54 inline bool Ray<T, D>::check_limits(T x) const
56 return x>=0 && (!limit || x<=limit);
59 } // namespace Geometry