-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlane.h
More file actions
37 lines (33 loc) · 772 Bytes
/
Plane.h
File metadata and controls
37 lines (33 loc) · 772 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
#ifndef PLANE_H
#define PLANE_H
#include "Object3D.h"
#include <vecmath.h>
#include <cmath>
using namespace std;
///TODO: Implement Plane representing an infinite plane
///choose your representation , add more fields and fill in the functions
class Plane: public Object3D
{
public:
Plane(){}
Plane( const Vector3f& normal , float d , Material* m):Object3D(m){
this->d = d;
this->normal = normal;
this->type = 'P';
}
~Plane(){}
virtual bool intersect( const Ray& r , Hit& h , float tmin)
{
float t = -(-d + Vector3f::dot(normal, r.getOrigin())) / Vector3f::dot(normal, r.getDirection());
if (t > tmin && t < h.getT())
{
h.set(t, material, normal);
return true;
}
return false;
}
protected:
float d;
Vector3f normal;
};
#endif //PLANE_H