-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ray.h
62 lines (48 loc) · 1000 Bytes
/
Ray.h
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef RAY_H
#define RAY_H
#include <cassert>
#include <iostream>
#include <Eigen\Geometry>
using namespace std;
using namespace Eigen;
// Ray class mostly copied from Peter Shirley and Keith Morley
class Ray
{
public:
Ray( const Vector3f& orig, const Vector3f& dir )
{
origin = orig;
direction = dir;
}
Ray( const Ray& r )
{
origin = r.origin;
direction = r.direction;
}
const Vector3f& getOrigin() const
{
return origin;
}
const Vector3f& getDirection() const
{
return direction;
}
Vector3f pointAtParameter( float t ) const
{
return origin + direction * t;
}
private:
// don't use this constructor
Ray()
{
assert( false );
}
Vector3f origin;
Vector3f direction;
};
inline ostream& operator << ( ostream& os, const Ray& r)
{
os << "Ray <" << r.getOrigin() << ", " << r.getDirection() << ">";
return os;
}
#endif // RAY_H