-
Notifications
You must be signed in to change notification settings - Fork 1
/
ray.h
42 lines (31 loc) · 1.02 KB
/
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
#ifndef _RAY_H
#define _RAY_H
#include <iostream>
#include "vectors.h"
// Ray class mostly copied from Peter Shirley and Keith Morley
// ====================================================================
// ====================================================================
class Ray {
public:
// CONSTRUCTOR & DESTRUCTOR
Ray (const Vec3f &orig, const Vec3f &dir) {
origin = orig;
direction = dir; }
// ACCESSORS
const Vec3f& getOrigin() const { return origin; }
const Vec3f& getDirection() const { return direction; }
Vec3f pointAtParameter(double t) const {
return origin+direction*t; }
private:
Ray () { assert(0); } // don't use this constructor
// REPRESENTATION
Vec3f origin;
Vec3f direction;
};
inline std::ostream &operator<<(std::ostream &os, const Ray &r) {
os << "Ray <" <<r.getOrigin()<<", "<<r.getDirection()<<">";
return os;
}
// ====================================================================
// ====================================================================
#endif