-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRay.cpp
More file actions
41 lines (31 loc) · 912 Bytes
/
Copy pathRay.cpp
File metadata and controls
41 lines (31 loc) · 912 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
34
35
36
37
38
39
40
41
#include "Ray.h"
namespace RayTracer {
Ray::Ray() : origin({0, 0, 0}), direction({0, 0, 1}) {}
Ray::Ray(const glm::vec3& origin, const glm::vec3& direction) : origin(origin), direction(glm::normalize(direction)) {}
void Ray::deviateVec(glm::vec3& vec, const float magnitude)
{
const auto deviation = glm::vec3{magnitude, magnitude, magnitude};
vec += deviation;
}
void Ray::deviate(const float magnitude)
{
deviateDirection(magnitude);
deviateOrigin(magnitude);
}
void Ray::deviateDirection(const float magnitude)
{
deviateVec(direction, magnitude);
}
void Ray::deviateOrigin(const float magnitude)
{
deviateVec(origin, magnitude);
}
glm::vec3 Ray::getDirection() const
{
return direction;
}
glm::vec3 Ray::getOrigin() const
{
return origin;
}
} // RayTracer