ray.cc 784 Bytes
Newer Older
1
2
3

#include "radixmath/ray.hh"
#include <iomanip>
4
5
#include <sstream>
namespace radix {
6
7
8
Ray::Ray(void)
    : o(0.0)
    , d(0.0, 0.0, 1.0) {}
9

10
11
12
Ray::Ray(const Point3D &origin, const Vector3D &dir)
    : o(origin)
    , d(dir) {}
13

14
15
16
Ray::Ray(const Ray &ray)
    : o(ray.o)
    , d(ray.d) {}
17

18
19
Ray &Ray::operator=(const Ray &rhs) {
  if (this == &rhs) return (*this);
20

21
22
  o = rhs.o;
  d = rhs.d;
23

24
  return (*this);
25
26
}

27
28
29
30
31
32
33
Ray::~Ray(void) {}
std::string Ray::toString() const {
  std::stringstream stream;
  stream << std::setprecision(13);
  stream << "o=[" << o.x << ", " << o.y << ", " << o.z << "] d=[" << d.x << ", "
         << d.y << ", " << d.z << "]";
  return stream.str();
34
35
}

36
37
std::ostream &operator<<(std::ostream &os, const Ray &r) {
  return os << r.toString();
38
}
39
}  // namespace radix