/
Plane.cpp
56 lines (48 loc) · 1.02 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "Plane.h"
Plane::Plane(Vector3 point, Vector3 ortho, PhongProp phong):
point(point), ortho(ortho), phong(phong)
{
reflect_index = 0;
reflective = false;
}
Plane::Plane(Vector3 point, Vector3 ortho, PhongProp phong, Color c):
point(point), ortho(ortho), phong(phong), color(c)
{
reflect_index = 0;
reflective = false;
}
double Plane::intersect(Ray *r){
double top = r->point.minus(point).dot(ortho);
double bottom = r->d.dot(ortho);
if (bottom == 0){
return -1;
} else {
double t = (top * -1) / bottom;
if (t > 0){
return t;
} else {
return -1;
}
}
}
PhongProp Plane::getPhong(){
return phong;
}
Color Plane::getColor(){
return color;
}
Vector3 Plane::getOrtho(Vector3 *point){
return ortho;
}
Vector3 Plane::point_above(Vector3 *point){
return point->add(ortho.Scale(.01));
}
bool Plane::is_reflective(){
return reflective;
}
double Plane::get_reflect(){
return reflect_index;
}
Plane::~Plane()
{
}