This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtests.cpp
72 lines (63 loc) · 2.74 KB
/
tests.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
62
63
64
65
66
67
68
69
70
71
72
#include "tests.hpp"
void testGeometry() {
cout << "running testGeometry" << endl;
cout << "Creating Variables" << endl;
// Variable Declarations
// Points
const Point a = Point(0, 0), b = Point(100, 100), c = Point(0, 100);
const Point e = Point(200, 0), d = Point(100, 0), f = Point(100, 200);
// Poly's
const cnt tri {a, e, b}; // non-equal sides
const cnt square {a, c, b, d};
const cnt rect {a, c*2, f, d};
const cnt bigSquare {a*2-b, c*2-b, b*2-b, d*2-b};
// Fp's
const Fp testFp1 = Fp({bigSquare, square});
const Fp testFp2 = Fp({bigSquare}); // not a valid Fp
const Fp testFp3 = Fp({square}); // not a valid Fp
cout << "Creating Vectors" << endl;
// Vectors
// Poly's
const vector<cnt> vpoly1 {tri, square, bigSquare};
const vector<cnt> vpoly2 {tri, square};
const vector<cnt> vpoly3 {square, bigSquare};
const vector<cnt> vpoly4 {tri, bigSquare};
const vector<cnt> vpoly5 {tri};
const vector<cnt> vpoly6 {square};
const vector<cnt> vpoly7 {bigSquare};
// Fp's
const vector<Fp> vfp1 {testFp1, testFp2, testFp3};
const vector<Fp> vfp2 {testFp1, testFp2};
const vector<Fp> vfp3 {testFp2, testFp3};
const vector<Fp> vfp4 {testFp1, testFp3};
const vector<Fp> vfp5 {testFp1};
const vector<Fp> vfp6 {testFp2};
const vector<Fp> vfp7 {testFp3};
cout << "Test Methods..." << endl;
// Test Methods
// Centroid
Point tric = centroid(tri);
Point squarec = centroid(square);
Point bigsc = centroid(bigSquare);
cout << "Triangle" << tostr(tri) << tostr(tric) << endl;
cout << "Square" << tostr(square) << tostr(squarec) << endl;
cout << "Big Square" << tostr(bigSquare) << tostr(bigsc) << endl;
cout << "Square & BigSquare Centroid: " << tostr(centroid(vpoly3)) << endl;
// Dist & Angs
vector<double> dts = dists(tri);
vector<double> ans = angles(tri);
cout << "Triangle lengths: " << vtostr(dts) << endl;
cout << "Triangle angles: " << vtostr(ans) << endl;
cout << "Unit Angle: " << "Origin - " << tostr(a) << "; Point - " << tostr(b) << "; Ang - " << angle(a,b) << endl;
// All same length
cout << "Triangle all same length? " << allSameLength(tri, (double)0.0) << endl;
cout << "Square all same length? " << allSameLength(square, (double)0.0) << endl;
// isPoly
bool test1 = isPoly(tri, 3, false, false, 0, 0); // True
bool test2 = isPoly(tri, 3, true, true, 0, 0); // False
bool test3 = isPoly(tri, 4, false, false, 0, 0); // False
bool test4 = isRectangle(rect, false, 0, 0); // True
bool test5 = isRectangle(rect, true, 0, 0); // False
bool test6 = isSquare(square, 0, 0); // True
cout << test1 << test2 << test3 << test4 << test5 << test6 << endl;
}