C++ / OpenCL Raytracer
ray.h
1 #ifndef RAY_H
2 #define RAY_H
3 
4 #include "vector.h"
5 
7 class Ray {
8 public:
9  Ray() {}
16  Ray(const Vector3D &a, const Vector3D &b) : m_vA(a), m_vB(b) {
17  m_vA = a; m_vB = b;
18  m_vInvDir = 1 / m_vB;
19  m_iSign[0] = (m_vInvDir.x() < 0);
20  m_iSign[1] = (m_vInvDir.y() < 0);
21  m_iSign[2] = (m_vInvDir.z() < 0);
22  m_vUnitDirection = UnitVector(m_vB);
23  }
24 
25  Vector3D Origin() const { return m_vA; }
26  Vector3D Direction() const { return m_vB; }
27  Vector3D PointAtParameter(double t) const { return m_vA + t * m_vB; }
28 
29  int m_iSign[3];
34 };
35 #endif // RAY_H
Ray(const Vector3D &a, const Vector3D &b)
Definition: ray.h:16
double y() const
Returns second (Y) location parameter in Vector3D.
Definition: vector.h:41
int m_iSign[3]
Array of 0 or 1 values dependent on InvDir of x(0), y(1), or z(2) value of Ray.
Definition: ray.h:29
Vector3D m_vInvDir
Inverted direction of Ray.
Definition: ray.h:32
Vector3D m_vUnitDirection
UnitVector Vector3D of Ray Direction.
Definition: ray.h:33
double z() const
Returns third (Z) location parameter in Vector3D.
Definition: vector.h:42
Vector3D Origin() const
Returns Vector3D starting location of Ray.
Definition: ray.h:25
Vector3D m_vB
Ending location of Ray; Direction.
Definition: ray.h:31
double x() const
Returns first (X) location parameter in Vector3D.
Definition: vector.h:40
Definition: vector.h:16
Vector3D Direction() const
Returns Vector3D ending location of Ray.
Definition: ray.h:26
Vector3D PointAtParameter(double t) const
Returns Vector3D location on ray based on given t value.
Definition: ray.h:27
Vector3D m_vA
Starting location of Ray; Origin.
Definition: ray.h:30
Definition: ray.h:7