-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathray.h
40 lines (29 loc) · 778 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
#pragma once
#include "vec3.h"
class ray
{
private:
point3 ori;
vec3 dir;
double time;
public:
ray() : ori(point3(0, 0, 0)), dir(vec3(0, 0, 0)), time(0) {}
ray(const point3& origin, const vec3& direction) : ori(origin), dir(direction), time(0) {}
ray(const point3& origin, const vec3& direction, double t) : ori(origin),
dir(direction), time(t) {}
const point3& origin() const noexcept {
return ori;
}
const vec3& direction() const noexcept
{
return dir;
}
double get_time() const noexcept
{
return time;
}
point3 at(double t) const
{
return ori + t * dir;
}
};