-
Notifications
You must be signed in to change notification settings - Fork 0
/
vxRay_UT.cpp
61 lines (48 loc) · 1.33 KB
/
vxRay_UT.cpp
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
/**
*
* file vxRay_UT.cpp
*
* This test file is a part of VoxelBrain software.
*
* (c) Nanyang Technological University
*
* Author: Konstantin Levinski
*
*/
#include <gtest/gtest.h>
#include "vxRay.h"
#include "vxSurface.h"
TEST(MAIN, RaySimple){
Intersection a;
Intersection b;
b.distance = 30;
a = b;
EXPECT_FALSE(a.hit);
EXPECT_EQ(a.distance, 30);
};
//Reports first intersection with the ray.
//If hit_point.distance < 0, then the intersection happened behind
//the ray origin, and is probably to be discarded, depending on the
//requrements.
TEST(MAIN, RaySphere){
Ray test(V3f(0,0,-3000), V3f(0,0,1));
Intersection touch_point = IntersectRaySphere(test, V3f(0,0,0), 3);
EXPECT_TRUE(touch_point.hit);
printf("distance: %f\n", touch_point.distance);
say("Touchdown at:", test.Travel(touch_point.distance));
};
TEST(MAIN, IntersectRaySurface){
Surface surf;
struct: V3fMapper {
V3f operator() (V3f in) {return in;};
} plane ;
GenerateSurface(surf, plane);
Intersection test;
Ray dir(V3f(0,0,-3000), V3f(0,0,1));
Ray wrong(V3f(30,-30,30), V3f(0,1,0));
EXPECT_TRUE((test = IntersectRaySurface(dir, & surf)).hit);
EXPECT_FALSE(IntersectRaySurface(wrong, & surf).hit);
EXPECT_EQ(10000, surf.v.size());
printf("distance to the surface: %f\n", test.distance);
};
//End of vxRay_UT.cpp