-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (37 loc) · 1.92 KB
/
main.cpp
File metadata and controls
48 lines (37 loc) · 1.92 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
#include <iostream>
#include "Vector3.h"
#include "Matrix4x4.h"
#include "Quaternion.h"
#include "Utilis.h"
#include "Line.h"
#include "Plane.h"
int main() {
Line FirstA = Line(Vector3(-2,5,0),Vector3(3,1,5));
Line FirstB = Line(Vector3(-2,4,0),Vector3(1,-5,3));
std::cout << "They intersect at point: " << FirstA.Intersect(FirstB).toString() << ".\n";
std::cout << "And they have angle of: " << std::to_string(FirstA.Angle(FirstB)) << " radians between them.\n";
Line ThirdA = Line(Vector3(-2,2,-1),Vector3(-5,3,-3));
Plane ThirdB = Plane(Vector3(0,8.0f/3,0),Vector3(4,0,0),Vector3(0,5.0f/3,1));
std::cout << "They intersect at point: " << ThirdB.Intersect(ThirdA).toString() << ".\n";
std::cout << "And they have angle of: " << std::to_string(ThirdB.Angle(ThirdA)) << " radians between them.\n";
Plane FiveA = Plane(Vector3(0,-8,0),Vector3(4,0,0),Vector3(0,0,8));
Plane FiveB = Plane(Vector3(0,-14.0f/3,0),Vector3(-7.0f/2,0,0),Vector3(1,0,-18));
std::cout << "They intersect at point: " << FiveA.Intersect(FiveB).toString() << ".\n";
std::cout << "And they have angle of: " << std::to_string(FiveA.Angle(FiveB)) << " radians between them.\n";
Line SevenA = Line(Vector3(5,5,4),Vector3(10,10,6));
Line SevenB = Line(Vector3(5,5,5),Vector3(10,10,3));
std::cout << "They intersect at point: " << SevenA.Intersect(SevenB).toString() << ".\n";
std::cout << "And they have angle of: " << std::to_string(SevenA.Angle(SevenB)) << " radians between them.\n";
Sphere NineA = Sphere(Vector3(0,0,0), sqrt(26));
Line NineB = Line(Vector3(3,-1,-2),Vector3(5,3,-4));
Vector3 returnPoints[2];
int howMany = NineB.Intersect(NineA,returnPoints);
if(howMany > 0){
for (int i = 0; i < howMany; ++i) {
std::cout << "They intersect at point: " << returnPoints[i].toString() << ".\n";
}
}else{
std::cout << "They don't intersect!";
}
return 0;
}