-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRay.h
More file actions
66 lines (55 loc) · 1.8 KB
/
Ray.h
File metadata and controls
66 lines (55 loc) · 1.8 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
// ----------------------------------------------------------------------------------------------------
//
// File name: Ray.h
// Created By: Haard Panchal
// Create Date: 03/11/2020
//
// Description:
// File has the definition and implementation of the Ray class
// Ray is defined as:
// P = P_0 + t * N;
// where P is the arbitrary point, P_0 is the initial point and N is direction of the ray
// t is the parameter
//
// History:
// 03/13/19: H. Panchal Created the file
//
// Declaration:
// N/A
//
// ----------------------------------------------------------------------------------------------------
#ifndef RAYH
#define RAYH
#include "Vector3.h"
/* Class: Ray
//
// Defines the implementation of the Ray.
//
// Constructor Parameters:
// TODO
//
// Return:
// TODO
*/
class Ray {
private:
Vector3 p_0; // The starting point of the ray
Vector3 n; // The direction of the ray
public:
__host__ __device__ Ray();
__host__ __device__ Ray(const Vector3& point, const Vector3& direction);
__host__ __device__ ~Ray();
__host__ __device__ inline Vector3 getPoint(float t) const; // Get a point t distance away from the starting point
__host__ __device__ inline Vector3 getStartingPoint() const { return p_0; } // Get the starting point of the ray
__host__ __device__ inline Vector3 getDirection() const { return n; } // Get the direction of the ray
};
__host__ __device__ Ray::Ray() {}
__host__ __device__ Ray::Ray(const Vector3& point, const Vector3& direction) : p_0(point) {
n = direction;
n.make_unit_vector();
}
__host__ __device__ inline Vector3 Ray::getPoint(float t) const {
return p_0 + t * n; // Returns the point calculated using the passed paramter
}
__host__ __device__ Ray::~Ray() {}
#endif