-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplane.cpp
More file actions
26 lines (22 loc) · 805 Bytes
/
Copy pathplane.cpp
File metadata and controls
26 lines (22 loc) · 805 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
#include "plane.h"
#include "intersection.h"
#include "material.h"
#include "tuple.h"
Plane::Plane(const Material &material) : Shape(material) {}
RayVector Plane::local_normal_at(const RayPoint &, const Intersection *) const {
return RayVector(0, 1, 0);
}
std::vector<Intersection> Plane::local_intersects(const Ray &local_ray) const {
std::vector<Intersection> intersections;
if (std::abs(local_ray.direction.y) < EPSILON) {
return intersections;
} else {
double t = -local_ray.origin.y / local_ray.direction.y;
intersections.push_back(Intersection(t, const_cast<Plane *>(this)));
return intersections;
}
}
BoundingBox Plane::bounds_of() const {
double inf = std::numeric_limits<double>::infinity();
return BoundingBox(RayPoint(-inf, 0, -inf), RayPoint(inf, 0, inf));
}