-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathray.h
More file actions
33 lines (22 loc) · 656 Bytes
/
ray.h
File metadata and controls
33 lines (22 loc) · 656 Bytes
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
//
// Created by 13240 on 2025/10/14.
//
#ifndef SIMPLE_SOFTRT_RAY_H
#define SIMPLE_SOFTRT_RAY_H
#include "vec3.h"
// ray = origin + dir
class ray {
public:
ray() {}
ray(const point3 &origin, const vec3 &direction, double time) : orig(origin), dir(direction), tm(time) {}
ray(const point3 &origin, const vec3 &direction) : ray(origin, direction, 0) {}
const point3 &origin() const { return orig; }
const vec3 &direction() const { return dir; }
point3 at(double t) const { return orig + dir * t; }
double time() const {return tm;}
private:
point3 orig;
vec3 dir;
double tm;
};
#endif //SIMPLE_SOFTRT_RAY_H