-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
98 lines (75 loc) · 3.19 KB
/
Copy pathmain.cpp
File metadata and controls
98 lines (75 loc) · 3.19 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "mainwindow.h"
#include <QApplication>
#include <ray.h>
#include <QDebug>
void testRayIntersection()
{
Ray r1, r2;
glm::vec3 ip;
Ray::RayIntersectionType status;
glm::vec3 dir, n;
qDebug() << "testing YZ plane";
r1 = Ray(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
r2 = Ray(glm::vec3(0.0f, 2.0f, 2.0f), glm::vec3(0.0f, 1.0f, 0.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
r1 = Ray(glm::vec3(10.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
r2 = Ray(glm::vec3(10.0f, 2.0f, 2.0f), glm::vec3(0.0f, 1.0f, 0.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
r1 = Ray(glm::vec3(0.0f, 2.0f, 0.0f), glm::vec3(0.0f, -1.0f, 1.0f));
r2 = Ray(glm::vec3(0.0f, -2.0f, 0.0f), glm::vec3(0.0f, 1.0f, 1.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
r1 = Ray(glm::vec3(0 , 17.0215 , 19.4149), glm::vec3(0 , -0.213445 , 0.976955));
r2 = Ray(glm::vec3(0 , -17.0215 , 19.4149), glm::vec3(0 , 0.213445 , 0.976955));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
dir = ip - r1.origin();
n = glm::cross(dir, r1.direction());
qDebug() << glm::dot(n, n);
qDebug() << "testing XY plane";
r1 = Ray(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f));
r2 = Ray(glm::vec3(2.0f, 2.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
r1 = Ray(glm::vec3(0.0f, 0.0f, 10.0f), glm::vec3(1.0f, 0.0f, 0.0f));
r2 = Ray(glm::vec3(2.0f, 2.0f, 10.0f), glm::vec3(0.0f, 1.0f, 0.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
r1 = Ray(glm::vec3(0.0f, 2.0f, 1.0f), glm::vec3(1.0f, -1.0f, 0.0f));
r2 = Ray(glm::vec3(0.0f, -2.0f, 1.0f), glm::vec3(1.0f, 1.0f, 0.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
r1 = Ray(glm::vec3(0.0f, 2.0f, 1.0f), glm::vec3(1.0f, 1.0f, 0.0f));
r2 = Ray(glm::vec3(0.0f, -2.0f, 1.0f), glm::vec3(1.0f, -1.0f, 0.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
r1 = Ray(glm::vec3(0.0f, 2.0f, 2.0f), glm::vec3(1.0f, 1.0f, 0.0f));
r2 = Ray(glm::vec3(0.0f, -2.0f, 1.0f), glm::vec3(1.0f, -1.0f, 0.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
r1 = Ray(glm::vec3(0.0f, 2.0f, 1.0f), glm::vec3(1.0f, 1.0f, 0.0f));
r2 = Ray(glm::vec3(0.0f, -2.0f, 1.0f), glm::vec3(1.0f, 1.0f, 0.0f));
status = r1.intersection(r2, ip);
qDebug() << status;
qDebug() << ip.x << " , " << ip.y << " , " << ip.z;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
// perform ray intersection test
testRayIntersection();
return a.exec();
}