-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-4.cpp
More file actions
42 lines (34 loc) · 744 Bytes
/
test-4.cpp
File metadata and controls
42 lines (34 loc) · 744 Bytes
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
#include "Point3.h"
#include "Vector3.h"
#ifdef VM_INCLUDE_NAMESPACE
using namespace kh_vecmath;
#endif
template<class T, class S>
bool equals(T a, S b) {
return fabs(a - b) < 1.0e-8;
}
/**
* test for Point3
*/
#ifdef TESTALL
int test_4() {
#else
int main(int, char**) {
#endif
Point3d p1(1,2,3);
Point3d p2(4,6,1);
// distance
Point3d::value_type d = p1.distance(p2);
Vector3d dv = p2 - p1;
assert(equals(d, dv.length()));
// distance L1
d = p1.distanceL1(p2);
assert(d == 9);
// distance Linf
d = p1.distanceLinf(p2);
assert(d == 4);
// project
p1.project(Point4d(6, 4, 2, 2));
assert(p1 == Point3d(3, 2, 1));
return 0;
}