-
Notifications
You must be signed in to change notification settings - Fork 0
/
plane.cpp
39 lines (34 loc) · 806 Bytes
/
plane.cpp
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
// Student Name: Jackson Hoke
// Student ID: 862161195
#include "plane.h"
#include "hit.h"
#include "ray.h"
#include <cfloat>
#include <limits>
Plane::Plane(const Parse* parse,std::istream& in)
{
in>>name>>x>>normal;
normal=normal.normalized();
}
// Intersect with the plane. The plane's normal points outside.
Hit Plane::Intersection(const Ray& ray, int part) const
{
Hit rt;
double denominator = dot(normal, ray.direction);
if (abs(denominator) <= small_t) {
return rt;
}
double t = dot(x-ray.endpoint, normal)/denominator;
if (t>small_t) rt.dist=t;
return rt;
}
vec3 Plane::Normal(const Ray& ray, const Hit& hit) const
{
return normal;
}
std::pair<Box,bool> Plane::Bounding_Box(int part) const
{
Box b;
b.Make_Full();
return {b,true};
}