]> git.tdb.fi Git - libs/math.git/blob - source/geometry/ray.h
Beginnings of a geometry library
[libs/math.git] / source / geometry / ray.h
1 #ifndef MSP_GEOMETRY_RAY_H_
2 #define MSP_GEOMETRY_RAY_H_
3
4 #include <msp/linal/vector.h>
5
6 namespace Msp {
7 namespace Geometry {
8
9 template<typename T, unsigned D>
10 class Ray
11 {
12 private:
13         LinAl::Vector<T, D> start;
14         LinAl::Vector<T, D> direction;
15
16 public:
17         Ray();
18         Ray(const LinAl::Vector<T, D> &, const LinAl::Vector<T, D> &);
19
20         const LinAl::Vector<T, D> &get_start() const { return start; }
21         const LinAl::Vector<T, D> &get_direction() const { return direction; }
22 };
23
24 template<typename T, unsigned D>
25 Ray<T, D>::Ray()
26 {
27         direction[0] = 1;
28 }
29
30 template<typename T, unsigned D>
31 Ray<T, D>::Ray(const LinAl::Vector<T, D> &s, const LinAl::Vector<T, D> &d):
32         start(s),
33         direction(normalize(d))
34 { }
35
36 } // namespace Geometry
37 } // namespace Msp
38
39 #endif