-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRay.h
More file actions
73 lines (60 loc) · 1.32 KB
/
Ray.h
File metadata and controls
73 lines (60 loc) · 1.32 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* Bijan Hamidi & Ruth Obidah
* bhamidi@csu.fullerton.edu, ruthobidah@csu.fullerton.edu
* CS 599 Independent Study
* December 2017
*
* $Id: Ray.h 1961 2017-12-05 08:46:53Z mshafae $
*
*/
#include <iostream>
#include <vector>
#include "glm/glm.hpp"
#include "glm/gtc/epsilon.hpp"
#include "glm/gtx/string_cast.hpp"
#ifndef _RAY_H_
#define _RAY_H_
class Ray{
glm::vec3 _p;
glm::vec3 _d;
glm::vec3 _ray = _p + _d;
int _i; //pixel coord
int _j; //pixel coord
public:
Ray(glm::vec3 p, glm::vec3 d, int i, int j): _p(p), _d(d), _i(i), _j(j){
// d should be a unit length vector plus or minus epsilon
//assert(glm::length2(d) < 1.000001);
assert(glm::epsilonEqual(glm::length(d), 1.0f, 0.00001f));
};//initalize data members without going into constructor
/* //construct this one from previoius - complier cant tell the difference
Ray(glm::vec3 p0, glm::vec3 p1): _p(p1){
_d = (p0 - p1);
_d = _d / length(_d);
}
*/
~Ray( ){};
glm::vec3 getPoint()
{
return _p;
}
glm::vec3 getDirection()
{
return _d;
}
glm::vec3 getRay()
{
return _ray;
}
int getX()
{
return _i;
}
int getY()
{
return _j;
}
std::ostream& write(std::ostream &out) const {
out << "Ray(p = " << glm::to_string(_p) << ", d = " << glm::to_string(_d) << ", i = " << _i << ", j = " << _j << std::endl;
return out;
}
};
#endif