-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestFindOuterPointSequenceSimple.m
200 lines (191 loc) · 9.56 KB
/
TestFindOuterPointSequenceSimple.m
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Core Model, 2022
% Written by Maya Davis
% Concept by Maya Davis and Melissa A. Redford
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% METHODS TESTED
%
%
%% TESTS
function tests = TestFindOuterPointSequenceSimple()
tests = functiontests(localfunctions);
end
function TestFunctionOneRegionSimple(testCase)
Region1 = WeightedMotorSimplicialComplex([1 7; 1 14; 7 7; 7 14], [1 3 4; 1 2 4], [1 1]);
RegionsToCombine = [Region1];
[actPointA, actPointB, actPointC, actPointD, actPointE, actPointF, ...
actPointG, actPointH, actOuterPointSequence, ...
actUpperRight, actUpperLeft, actLowerRight, actLowerLeft, ...
actCIndex, actEIndex, actGIndex, actLastIndex] = ...
FindOuterPointSequence(RegionsToCombine);
expPointA = [1; 14];
expPointB = [7; 14];
expPointC = [7; 14];
expPointD = [7; 7];
expPointE = [7; 7];
expPointF = [1; 7];
expPointG = [1; 7];
expPointH = [1; 14];
expOuterPointSequence = [1 7 7 1; 14 14 7 7];
expUpperRight = [7; 14];
expUpperLeft = [1; 14];
expLowerRight = [7; 7];
expLowerLeft = [1; 7];
expCIndex = 2;
expEIndex = 3;
expGIndex = 4;
expLastIndex = 4;
verifyEqual(testCase, actPointA, expPointA, "AbsTol", 0.00001);
verifyEqual(testCase, actPointB, expPointB, "AbsTol", 0.00001);
verifyEqual(testCase, actPointC, expPointC, "AbsTol", 0.00001);
verifyEqual(testCase, actPointD, expPointD, "AbsTol", 0.00001);
verifyEqual(testCase, actPointE, expPointE, "AbsTol", 0.00001);
verifyEqual(testCase, actPointF, expPointF, "AbsTol", 0.00001);
verifyEqual(testCase, actPointG, expPointG, "AbsTol", 0.00001);
verifyEqual(testCase, actPointH, expPointH, "AbsTol", 0.00001);
verifyEqual(testCase, actOuterPointSequence, expOuterPointSequence, "AbsTol", 0.00001);
verifyEqual(testCase, actUpperRight, expUpperRight, "AbsTol", 0.00001);
verifyEqual(testCase, actUpperLeft, expUpperLeft, "AbsTol", 0.00001);
verifyEqual(testCase, actLowerRight, expLowerRight, "AbsTol", 0.00001);
verifyEqual(testCase, actLowerLeft, expLowerLeft, "AbsTol", 0.00001);
verifyEqual(testCase, actCIndex, expCIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actEIndex, expEIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actGIndex, expGIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actLastIndex, expLastIndex, "AbsTol", 0.00001);
end
function TestFunctionDoubleRegionSimple(testCase)
Region1 = WeightedMotorSimplicialComplex([5 4; 5 12; 10 4; 10 12], [1 3 4; 1 2 4], [1 1]);
Region2 = WeightedMotorSimplicialComplex([5 4; 5 12; 10 4; 10 12], [1 3 4; 1 2 4], [1 1]);
RegionsToCombine = [Region1 Region2];
[actPointA, actPointB, actPointC, actPointD, actPointE, actPointF, ...
actPointG, actPointH, actOuterPointSequence, ...
actUpperRight, actUpperLeft, actLowerRight, actLowerLeft, ...
actCIndex, actEIndex, actGIndex, actLastIndex] = ...
FindOuterPointSequence(RegionsToCombine);
expPointA = [5; 12];
expPointB = [10; 12];
expPointC = [10; 12];
expPointD = [10; 4];
expPointE = [10; 4];
expPointF = [5; 4];
expPointG = [5; 4];
expPointH = [5; 12];
expOuterPointSequence = [5 10 10 5; 12 12 4 4];
expUpperRight = [10 10; 12 12];
expUpperLeft = [5 5; 12 12];
expLowerRight = [10 10; 4 4];
expLowerLeft = [5 5; 4 4];
expCIndex = 2;
expEIndex = 3;
expGIndex = 4;
expLastIndex = 4;
verifyEqual(testCase, actPointA, expPointA, "AbsTol", 0.00001);
verifyEqual(testCase, actPointB, expPointB, "AbsTol", 0.00001);
verifyEqual(testCase, actPointC, expPointC, "AbsTol", 0.00001);
verifyEqual(testCase, actPointD, expPointD, "AbsTol", 0.00001);
verifyEqual(testCase, actPointE, expPointE, "AbsTol", 0.00001);
verifyEqual(testCase, actPointF, expPointF, "AbsTol", 0.00001);
verifyEqual(testCase, actPointG, expPointG, "AbsTol", 0.00001);
verifyEqual(testCase, actPointH, expPointH, "AbsTol", 0.00001);
verifyEqual(testCase, actOuterPointSequence, expOuterPointSequence, "AbsTol", 0.00001);
verifyEqual(testCase, actUpperRight, expUpperRight, "AbsTol", 0.00001);
verifyEqual(testCase, actUpperLeft, expUpperLeft, "AbsTol", 0.00001);
verifyEqual(testCase, actLowerRight, expLowerRight, "AbsTol", 0.00001);
verifyEqual(testCase, actLowerLeft, expLowerLeft, "AbsTol", 0.00001);
verifyEqual(testCase, actCIndex, expCIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actEIndex, expEIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actGIndex, expGIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actLastIndex, expLastIndex, "AbsTol", 0.00001);
end
function TestFunctionSimple(testCase)
Region1 = WeightedMotorSimplicialComplex([1 7; 1 14; 7 7; 7 14], [1 3 4; 1 2 4], [1 1]);
Region2 = WeightedMotorSimplicialComplex([2 1; 2 10; 12 1; 12 10], [1 3 4; 1 2 4], [1 1]);
Region3 = WeightedMotorSimplicialComplex([5 4; 5 12; 10 4; 10 12], [1 3 4; 1 2 4], [1 1]);
RegionsToCombine = [Region1 Region2 Region3];
[actPointA, actPointB, actPointC, actPointD, actPointE, actPointF, ...
actPointG, actPointH, actOuterPointSequence, ...
actUpperRight, actUpperLeft, actLowerRight, actLowerLeft, ...
actCIndex, actEIndex, actGIndex, actLastIndex] = ...
FindOuterPointSequence(RegionsToCombine);
expPointA = [1; 14];
expPointB = [7; 14];
expPointC = [12; 10];
expPointD = [12; 1];
expPointE = [12; 1];
expPointF = [2; 1];
expPointG = [1; 7];
expPointH = [1; 14];
expOuterPointSequence = [1 7 10 12 12 2 1; 14 14 12 10 1 1 7];
expUpperRight = [7 12 10; 14 10 12];
expUpperLeft = [1 2 5; 14 10 12];
expLowerRight = [7 12 10; 7 1 4];
expLowerLeft = [1 2 5; 7 1 4];
expCIndex = 4;
expEIndex = 5;
expGIndex = 7;
expLastIndex = 7;
verifyEqual(testCase, actPointA, expPointA, "AbsTol", 0.00001);
verifyEqual(testCase, actPointB, expPointB, "AbsTol", 0.00001);
verifyEqual(testCase, actPointC, expPointC, "AbsTol", 0.00001);
verifyEqual(testCase, actPointD, expPointD, "AbsTol", 0.00001);
verifyEqual(testCase, actPointE, expPointE, "AbsTol", 0.00001);
verifyEqual(testCase, actPointF, expPointF, "AbsTol", 0.00001);
verifyEqual(testCase, actPointG, expPointG, "AbsTol", 0.00001);
verifyEqual(testCase, actPointH, expPointH, "AbsTol", 0.00001);
verifyEqual(testCase, actOuterPointSequence, expOuterPointSequence, "AbsTol", 0.00001);
verifyEqual(testCase, actUpperRight, expUpperRight, "AbsTol", 0.00001);
verifyEqual(testCase, actUpperLeft, expUpperLeft, "AbsTol", 0.00001);
verifyEqual(testCase, actLowerRight, expLowerRight, "AbsTol", 0.00001);
verifyEqual(testCase, actLowerLeft, expLowerLeft, "AbsTol", 0.00001);
verifyEqual(testCase, actCIndex, expCIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actEIndex, expEIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actGIndex, expGIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actLastIndex, expLastIndex, "AbsTol", 0.00001);
end
function TestFunctionSimple2(testCase)
Region1 = WeightedMotorSimplicialComplex([1 7; 1 14; 7 7; 7 14], [1 3 4; 1 2 4], [1 1]);
Region2 = WeightedMotorSimplicialComplex([2 1; 2 10; 12 1; 12 10], [1 3 4; 1 2 4], [1 1]);
Region3 = WeightedMotorSimplicialComplex([5 4; 5 12; 10 4; 10 12], [1 3 4; 1 2 4], [1 1]);
Region4 = WeightedMotorSimplicialComplex([0 -5; 0 2; 8 -5; 8 2], [1 3 4; 1 2 4], [1 1]);
Region5 = WeightedMotorSimplicialComplex([6 2; 6 3; 9 2; 9 3], [1 3 4; 1 2 4], [1 1]);
RegionsToCombine = [Region1 Region2 Region3 Region4 Region5];
[actPointA, actPointB, actPointC, actPointD, actPointE, actPointF, ...
actPointG, actPointH, actOuterPointSequence, ...
actUpperRight, actUpperLeft, actLowerRight, actLowerLeft, ...
actCIndex, actEIndex, actGIndex, actLastIndex] = ...
FindOuterPointSequence(RegionsToCombine);
expPointA = [1; 14];
expPointB = [7; 14];
expPointC = [12; 10];
expPointD = [12; 1];
expPointE = [8; -5];
expPointF = [0; -5];
expPointG = [0; -5];
expPointH = [0; 2];
expOuterPointSequence = [1 7 10 12 12 8 0 0; 14 14 12 10 1 -5 -5 2];
expUpperRight = [7 12 10 8 9; 14 10 12 2 3];
expUpperLeft = [1 2 5 0 6; 14 10 12 2 3];
expLowerRight = [7 12 10 8 9; 7 1 4 -5 2];
expLowerLeft = [1 2 5 0 6; 7 1 4 -5 2];
expCIndex = 4;
expEIndex = 6;
expGIndex = 7;
expLastIndex = 8;
verifyEqual(testCase, actPointA, expPointA, "AbsTol", 0.00001);
verifyEqual(testCase, actPointB, expPointB, "AbsTol", 0.00001);
verifyEqual(testCase, actPointC, expPointC, "AbsTol", 0.00001);
verifyEqual(testCase, actPointD, expPointD, "AbsTol", 0.00001);
verifyEqual(testCase, actPointE, expPointE, "AbsTol", 0.00001);
verifyEqual(testCase, actPointF, expPointF, "AbsTol", 0.00001);
verifyEqual(testCase, actPointG, expPointG, "AbsTol", 0.00001);
verifyEqual(testCase, actPointH, expPointH, "AbsTol", 0.00001);
verifyEqual(testCase, actOuterPointSequence, expOuterPointSequence, "AbsTol", 0.00001);
verifyEqual(testCase, actUpperRight, expUpperRight, "AbsTol", 0.00001);
verifyEqual(testCase, actUpperLeft, expUpperLeft, "AbsTol", 0.00001);
verifyEqual(testCase, actLowerRight, expLowerRight, "AbsTol", 0.00001);
verifyEqual(testCase, actLowerLeft, expLowerLeft, "AbsTol", 0.00001);
verifyEqual(testCase, actCIndex, expCIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actEIndex, expEIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actGIndex, expGIndex, "AbsTol", 0.00001);
verifyEqual(testCase, actLastIndex, expLastIndex, "AbsTol", 0.00001);
end