-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRay.hpp
29 lines (24 loc) · 840 Bytes
/
Ray.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//
// Created by LEI XU on 5/16/19.
//
#ifndef RAYTRACING_RAY_H
#define RAYTRACING_RAY_H
#include "Vector.hpp"
struct Ray{
//Destination = origin + t*direction
Vector3f origin;
Vector3f direction, direction_inv;
double t;//transportation time,
double t_min, t_max;
Ray(const Vector3f& ori, const Vector3f& dir, const double _t = 0.0): origin(ori), direction(dir),t(_t) {
direction_inv = Vector3f(1./direction.x, 1./direction.y, 1./direction.z);
t_min = 0.0;
t_max = std::numeric_limits<double>::max();
}
Vector3f operator()(double t) const{return origin+direction*t;}
friend std::ostream &operator<<(std::ostream& os, const Ray& r){
os<<"[origin:="<<r.origin<<", direction="<<r.direction<<", time="<< r.t<<"]\n";
return os;
}
};
#endif //RAYTRACING_RAY_H