flash_math 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +17 -0
  4. data/.rspec +4 -0
  5. data/.travis.yml +13 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +187 -0
  9. data/Rakefile +6 -0
  10. data/flash_math.gemspec +27 -0
  11. data/lib/flash_math.rb +3 -0
  12. data/lib/flash_math/modules/geometry.rb +10 -0
  13. data/lib/flash_math/modules/geometry/geometric_bounding_box.rb +16 -0
  14. data/lib/flash_math/modules/geometry/geometric_distance.rb +20 -0
  15. data/lib/flash_math/modules/geometry/geometric_line.rb +87 -0
  16. data/lib/flash_math/modules/geometry/geometric_point.rb +19 -0
  17. data/lib/flash_math/modules/geometry/geometric_point_in_polygon.rb +63 -0
  18. data/lib/flash_math/modules/geometry/geometric_polygon.rb +36 -0
  19. data/lib/flash_math/modules/geometry/geometric_segment.rb +128 -0
  20. data/lib/flash_math/modules/geometry/geometric_vector.rb +46 -0
  21. data/lib/flash_math/modules/statistics.rb +1 -0
  22. data/lib/flash_math/modules/statistics/statistical_spread.rb +129 -0
  23. data/lib/flash_math/version.rb +3 -0
  24. data/spec/lib/geometry/geometric_bounding_box_spec.rb +67 -0
  25. data/spec/lib/geometry/geometric_distance_spec.rb +55 -0
  26. data/spec/lib/geometry/geometric_line_spec.rb +287 -0
  27. data/spec/lib/geometry/geometric_point_spec.rb +53 -0
  28. data/spec/lib/geometry/geometric_polygon_spec.rb +148 -0
  29. data/spec/lib/geometry/geometric_segment_spec.rb +231 -0
  30. data/spec/lib/geometry/geometric_vector_spec.rb +110 -0
  31. data/spec/lib/statistics/statistics_spread_spec.rb +219 -0
  32. data/spec/spec_helper.rb +4 -0
  33. metadata +168 -0
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeometricDistance do
4
+
5
+ describe '#initialize_by_numbers' do
6
+ distance = GeometricDistance.new(1, 2)
7
+
8
+ it 'to be equal' do
9
+ expect(distance.point1).to eq(1)
10
+ expect(distance.point2).to eq(2)
11
+ end
12
+
13
+ it 'to be not equal' do
14
+ expect(distance.point1).not_to eq(3)
15
+ expect(distance.point2).not_to eq(3)
16
+ end
17
+ end
18
+
19
+ describe '#initialize_by_array' do
20
+ point1 = GeometricPoint.new(1, 2)
21
+ point2 = GeometricPoint.new(1, 1)
22
+ distance = GeometricDistance.new_by_arrays([1, 2], [1, 1])
23
+
24
+ it 'to be equal' do
25
+ expect(distance.point1).to eq(point1)
26
+ expect(distance.point2).to eq(point2)
27
+ end
28
+
29
+ it 'to be not equal' do
30
+ expect(distance.point1).not_to eq(point2)
31
+ expect(distance.point2).not_to eq(point1)
32
+ end
33
+ end
34
+
35
+ describe '#distance' do
36
+ it 'to be distance between two points' do
37
+ expect(GeometricDistance.new_by_arrays([1, 1], [1, 2]).distance).to eq(1)
38
+ expect(GeometricDistance.new_by_arrays([1, 1], [2, 1]).distance).to eq(1)
39
+ expect(GeometricDistance.new_by_arrays([1, 1], [2, 2]).distance).to eq(1.4142135623730951)
40
+ end
41
+ end
42
+
43
+ describe '#midpoint' do
44
+ it 'to be midpoint' do
45
+ expect(GeometricDistance.new_by_arrays([1, 2], [3, 4]).midpoint).to eq([2, 3])
46
+ end
47
+ end
48
+
49
+ describe '#midpoint_distance' do
50
+ it 'to be half the distance between two points' do
51
+ expect(GeometricDistance.new_by_arrays([1, 1], [1, 2]).midpoint_distance).to eq(0.5)
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,287 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeometricLine do
4
+ infinity = 1.0 / 0.0
5
+
6
+ describe '#initialize_by_numbers' do
7
+ line = GeometricLine.new(1, 2)
8
+
9
+ it 'to be equal' do
10
+ expect(line.point1).to eq(1)
11
+ expect(line.point2).to eq(2)
12
+ end
13
+
14
+ it 'to be not equal' do
15
+ expect(line.point1).not_to eq(3)
16
+ expect(line.point2).not_to eq(3)
17
+ end
18
+ end
19
+
20
+ describe '#initialize_by_array' do
21
+ point1 = GeometricPoint.new(1, 2)
22
+ point2 = GeometricPoint.new(1, 1)
23
+ line = GeometricLine.new_by_arrays([1, 2], [1, 1])
24
+
25
+ it 'to be equal' do
26
+ expect(line.point1).to eq(point1)
27
+ expect(line.point2).to eq(point2)
28
+ end
29
+
30
+ it 'to be not equal' do
31
+ expect(line.point1).not_to eq(point2)
32
+ expect(line.point2).not_to eq(point1)
33
+ end
34
+ end
35
+
36
+ describe '#angle_to' do
37
+ line = GeometricLine.new_by_arrays([0, 0], [1, 1])
38
+
39
+ it 'to be angle to self' do
40
+ expect(line.angle_to(line)).to eq(0)
41
+ end
42
+
43
+ it 'to be angle to perpendicular' do
44
+ perp = GeometricLine.new_by_arrays([0, 0], [1, -1])
45
+ expect(line.angle_to(perp)).to eq(Math::PI / 2)
46
+ expect(perp.angle_to(line)).to eq(Math::PI / 2)
47
+ end
48
+
49
+ it 'to be angle to acute' do
50
+ acute = GeometricLine.new_by_arrays([0, 0], [0, 1])
51
+ expect(line.angle_to(acute)).to eq(Math::PI / 4)
52
+ expect(acute.angle_to(line)).to eq(Math::PI / 4)
53
+ end
54
+ end
55
+
56
+ describe '#distance_to' do
57
+ it 'to be point on line' do
58
+ line = GeometricLine.new_by_arrays([0, 2], [2, 0])
59
+ point = GeometricPoint.new(1, 1)
60
+ expect(line.distance_to(point)).to eq(0)
61
+ end
62
+
63
+ it 'to be flat line' do
64
+ line = GeometricLine.new_by_arrays([0, 1], [2, 1])
65
+ point = GeometricPoint.new(1, 2)
66
+ expect(line.distance_to(point)).to eq(1)
67
+ end
68
+ end
69
+
70
+ describe '#horizontal?' do
71
+ it 'to be horizontal' do
72
+ line = GeometricLine.new_by_arrays([0, 0], [1, 0])
73
+ expect(line.horizontal?).to eq(true)
74
+ end
75
+
76
+ it 'to be not horizontal' do
77
+ line = GeometricLine.new_by_arrays([0, 0], [1, 1])
78
+ expect(line.horizontal?).to eq(false)
79
+ end
80
+ end
81
+
82
+ describe '#intersect_x' do
83
+ it 'to be vertical non overlapping' do
84
+ line1 = GeometricLine.new_by_arrays([0, 0], [0, 1])
85
+ line2 = GeometricLine.new_by_arrays([1, 0], [1, 1])
86
+ expect(line1.intersect_x(line2).nil?).to eq(true)
87
+ end
88
+
89
+ it 'to be vertical overlapping' do
90
+ line1 = GeometricLine.new_by_arrays([0, 0], [0, 1])
91
+ line2 = GeometricLine.new_by_arrays([0, 0], [0, 1])
92
+ expect(line1.intersect_x(line2)).to eq(0)
93
+ expect(line2.intersect_x(line1)).to eq(0)
94
+ end
95
+
96
+ it 'to be horizontal non overlapping' do
97
+ line1 = GeometricLine.new_by_arrays([0, 0], [1, 0])
98
+ line2 = GeometricLine.new_by_arrays([0, 1], [1, 1])
99
+ expect(line1.intersect_x(line2).nil?).to eq(true)
100
+ end
101
+
102
+ it 'to be horizontal overlapping' do
103
+ line1 = GeometricLine.new_by_arrays([0, 0], [1, 0])
104
+ line2 = GeometricLine.new_by_arrays([0, 0], [1, 0])
105
+ expect(line1.intersect_x(line2).nil?).to eq(true)
106
+ end
107
+
108
+ it 'to be perpendicular' do
109
+ [-1, 0, 1].each do |xo|
110
+ [-1, 0, 1].each do |yo|
111
+ line1 = GeometricLine.new_by_arrays([xo, yo], [xo + 0, yo + 1])
112
+ line2 = GeometricLine.new_by_arrays([xo, yo], [xo + 1, yo + 0])
113
+ expect(line1.intersect_x(line2)).to eq(xo)
114
+ expect(line2.intersect_x(line1)).to eq(xo)
115
+ end
116
+ end
117
+ end
118
+ end
119
+
120
+ describe '#parallel_to?' do
121
+ it 'to be identical' do
122
+ (1..100).each do
123
+ point1 = [rand-0.5, rand-0.5]
124
+ point2 = [rand-0.5, rand-0.5]
125
+ line = GeometricLine.new_by_arrays(point1, point2)
126
+ expect(line.parallel_to?(line)).to eq(true)
127
+ end
128
+ end
129
+
130
+ it 'to be vertical' do
131
+ line1 = GeometricLine.new_by_arrays([0, 0], [0, 1])
132
+ line2 = GeometricLine.new_by_arrays([0, 0], [0, -1])
133
+ expect(line1.parallel_to?(line2)).to eq(true)
134
+ expect(line2.parallel_to?(line1)).to eq(true)
135
+ end
136
+
137
+ it 'to be horizontal' do
138
+ line1 = GeometricLine.new_by_arrays([0, 0], [-1, 0])
139
+ line2 = GeometricLine.new_by_arrays([0, 0], [1, 0])
140
+ expect(line1.parallel_to?(line2)).to eq(true)
141
+ expect(line2.parallel_to?(line1)).to eq(true)
142
+ end
143
+
144
+ it 'to be shifted' do
145
+ line1 = GeometricLine.new_by_arrays([0, 0], [1, 1])
146
+ line2 = GeometricLine.new_by_arrays([1, 0], [2, 1])
147
+ expect(line1.parallel_to?(line2)).to eq(true)
148
+ expect(line2.parallel_to?(line1)).to eq(true)
149
+ end
150
+
151
+ it 'to be not parallel' do
152
+ line1 = GeometricLine.new_by_arrays([0, 0], [-1, 1])
153
+ line2 = GeometricLine.new_by_arrays([0, 0], [1, -2])
154
+ expect(line1.parallel_to?(line2)).to eq(false)
155
+ expect(line2.parallel_to?(line1)).to eq(false)
156
+ end
157
+ end
158
+
159
+ describe '#slope' do
160
+ it 'to be vertical' do
161
+ [-1, 0, 1].each do |x|
162
+ line = GeometricLine.new(GeometricPoint.new(x, 0), GeometricPoint.new(x, 1))
163
+ expect(line.slope).to eq(infinity)
164
+ end
165
+ end
166
+
167
+ it 'to be vertical negative' do
168
+ [-1, 0, 1].each do |x|
169
+ line = GeometricLine.new(GeometricPoint.new(x, 0), GeometricPoint.new(x, -1))
170
+ expect(line.slope).to eq(-infinity)
171
+ end
172
+ end
173
+
174
+ it 'to be horizontal' do
175
+ [-1, 0, 1].each do |y|
176
+ line = GeometricLine.new(GeometricPoint.new(0, y), GeometricPoint.new(1, y))
177
+ expect(line.slope).to eq(0)
178
+ end
179
+ end
180
+
181
+ it 'to be horizontal negative' do
182
+ [-1, 0, 1].each do |y|
183
+ line = GeometricLine.new(GeometricPoint.new(0, y), GeometricPoint.new(-1, y))
184
+ expect(line.slope).to eq(0)
185
+ end
186
+ end
187
+
188
+ it 'to be full circle' do
189
+ delta = 0.000001
190
+ increment = Math::PI / 10
191
+ divisions = 2 * Math::PI / increment
192
+ radius = 1
193
+ (0..divisions).each do |d|
194
+ angle = d * increment
195
+ y = radius * Math::sin(angle)
196
+ x = radius * Math::cos(angle)
197
+ line = GeometricLine.new(GeometricPoint.new(0, 0), GeometricPoint.new(x, y))
198
+ expect(line.slope).to be_within(delta).of(Math::tan(angle))
199
+ end
200
+ end
201
+ end
202
+
203
+ describe '#vertical?' do
204
+ it 'to be vertical' do
205
+ line = GeometricLine.new_by_arrays([0, 0], [0, 1])
206
+ expect(line.vertical?).to eq(true)
207
+ end
208
+
209
+ it 'to be not vertical' do
210
+ line = GeometricLine.new_by_arrays([0, 0], [1, 1])
211
+ expect(line.vertical?).to eq(false)
212
+ end
213
+ end
214
+
215
+ describe '#x_intercept' do
216
+ it 'to be anchored at x axis' do
217
+ [-1, 0, 1].each do |xi|
218
+ line = GeometricLine.new(GeometricPoint.new(xi, 0), GeometricPoint.new(1, 1))
219
+ expect(line.x_intercept).to eq(xi)
220
+ end
221
+ end
222
+
223
+ it 'to be not floating' do
224
+ [-1, 1].each do |slope|
225
+ [-2, 0, 2].each do |yo|
226
+ [-1, 0, 1].each do |xi|
227
+ point1 = GeometricPoint.new(xi + yo / slope, yo)
228
+ point2 = GeometricPoint.new(xi + (yo + 1) / slope, yo + 1)
229
+ line = GeometricLine.new(point1, point2)
230
+ expect(line.x_intercept).to eq(xi)
231
+ end
232
+ end
233
+ end
234
+ end
235
+
236
+ it 'to be vertical' do
237
+ [-1, 0, 1].each do |xi|
238
+ line = GeometricLine.new(GeometricPoint.new(xi, 1), GeometricPoint.new(xi, 2))
239
+ expect(line.x_intercept).to eq(xi)
240
+ end
241
+ end
242
+
243
+ it 'to be horizontal' do
244
+ [-1, 0, 1].each do |yo|
245
+ line = GeometricLine.new(GeometricPoint.new(0, yo), GeometricPoint.new(1, yo))
246
+ expect(line.x_intercept.nil?).to eq(true)
247
+ end
248
+ end
249
+ end
250
+
251
+ describe '#y_intercept' do
252
+ it 'to be anchored at y axis' do
253
+ [-1, 0, 1].each do |yi|
254
+ line = GeometricLine.new(GeometricPoint.new(0, yi), GeometricPoint.new(1, 1))
255
+ expect(line.y_intercept).to eq(yi)
256
+ end
257
+ end
258
+
259
+ it 'to be not floating' do
260
+ [-1, 1].each do |slope|
261
+ [-2, 0, 2].each do |xo|
262
+ [-1, 0, 1].each do |yi|
263
+ point1 = GeometricPoint.new(xo, yi + slope * xo)
264
+ point2 = GeometricPoint.new(xo + 1, yi + slope * (xo + 1))
265
+ line = GeometricLine.new(point1, point2)
266
+ expect(line.y_intercept).to eq(yi)
267
+ end
268
+ end
269
+ end
270
+ end
271
+
272
+ it 'to be horizontal' do
273
+ [-1, 0, 1].each do |yi|
274
+ line = GeometricLine.new(GeometricPoint.new(1, yi), GeometricPoint.new(2, yi))
275
+ expect(line.y_intercept).to eq(yi)
276
+ end
277
+ end
278
+
279
+ it 'to be vertical' do
280
+ [-1, 0, 1].each do |xo|
281
+ line = GeometricLine.new(GeometricPoint.new(xo, 0), GeometricPoint.new(xo, 1))
282
+ expect(line.y_intercept.nil?).to eq(true)
283
+ end
284
+ end
285
+ end
286
+
287
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeometricPoint do
4
+ describe '#initialize_by_numbers' do
5
+ point = GeometricPoint.new(1, 2)
6
+
7
+ it 'to be equal' do
8
+ expect(point.x).to eq(1)
9
+ expect(point.y).to eq(2)
10
+ end
11
+
12
+ it 'to be not equal' do
13
+ expect(point.x).not_to eq(3)
14
+ expect(point.y).not_to eq(3)
15
+ end
16
+ end
17
+
18
+ describe '#initialize_by_array' do
19
+ point = GeometricPoint.new_by_array([1, 2])
20
+
21
+ it 'to be equal' do
22
+ expect(point.x).to eq(1)
23
+ expect(point.y).to eq(2)
24
+ end
25
+
26
+ it 'to be not equal' do
27
+ expect(point.x).not_to eq(3)
28
+ expect(point.y).not_to eq(3)
29
+ end
30
+ end
31
+
32
+ describe '#advance_by' do
33
+ it 'to be the addition of a point to a vector' do
34
+ point = GeometricPoint.new(1, 2)
35
+ vector = GeometricVector.new(2, -1)
36
+ expect(point.advance_by(vector)).to eq(GeometricPoint.new(3, 1))
37
+ end
38
+ end
39
+
40
+ describe '#to_vector' do
41
+ it 'to be converted to a vector' do
42
+ expect(GeometricPoint.new(1, 2).to_vector).to eq(GeometricVector.new(1, 2))
43
+ end
44
+ end
45
+
46
+ describe '#==' do
47
+ it 'to be converted to a vector' do
48
+ point = GeometricPoint.new(1, 2)
49
+ expect(point == point).to eq(true)
50
+ expect(point == GeometricPoint.new(1, 3)).to eq(false)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,148 @@
1
+ require 'spec_helper'
2
+
3
+ describe GeometricPolygon do
4
+ describe '#area' do
5
+ it 'to be area of an empty polygon' do
6
+ expect(GeometricPolygon.new([]).area).to eq(0)
7
+ end
8
+
9
+ it 'to be area of a point' do
10
+ expect(GeometricPolygon.new([GeometricPoint.new(1,1)]).area).to eq(0)
11
+ end
12
+
13
+ it 'to be area of a line' do
14
+ expect(GeometricPolygon.new([GeometricPoint.new(0,0), GeometricPoint.new(1,1)]).area).to eq(0)
15
+ end
16
+
17
+ it 'to be area of a triangle' do
18
+ expect(GeometricPolygon.new([GeometricPoint.new(0,0), GeometricPoint.new(1,1), GeometricPoint.new(0,1)]).area).to eq(0.5)
19
+ end
20
+
21
+ it 'to be area of a square' do
22
+ expect(GeometricPolygon.new([GeometricPoint.new(0,0), GeometricPoint.new(0,2), GeometricPoint.new(2,2), GeometricPoint.new(2,0)]).area).to eq(4)
23
+ end
24
+
25
+ it 'to be area of a quadralateral' do
26
+ expect(GeometricPolygon.new([GeometricPoint.new(4,10), GeometricPoint.new(9,7), GeometricPoint.new(11,2), GeometricPoint.new(2,2)]).area).to eq(45.5)
27
+ end
28
+ end
29
+
30
+ describe '#bounding_box' do
31
+ it 'to be a rectangle' do
32
+ polygon = GeometricPolygon.new([
33
+ GeometricPoint.new(-1, -1),
34
+ GeometricPoint.new(1, -1),
35
+ GeometricPoint.new(1, 1),
36
+ GeometricPoint.new(-1, 1)
37
+ ])
38
+ expect(polygon.bounding_box.leftbottom).to eq(GeometricPoint.new(-1, -1))
39
+ expect(polygon.bounding_box.righttop).to eq(GeometricPoint.new(1, 1))
40
+ end
41
+
42
+ it 'to be a sloped rectangle' do
43
+ polygon = GeometricPolygon.new([
44
+ GeometricPoint.new(-1, 0),
45
+ GeometricPoint.new(0, -1),
46
+ GeometricPoint.new(1, 0),
47
+ GeometricPoint.new(0, 1)
48
+ ])
49
+ expect(polygon.bounding_box.leftbottom).to eq(GeometricPoint.new(-1, -1))
50
+ expect(polygon.bounding_box.righttop).to eq(GeometricPoint.new(1, 1))
51
+ end
52
+
53
+ it 'to be nonconvex' do
54
+ polygon = GeometricPolygon.new([
55
+ GeometricPoint.new(0, 2),
56
+ GeometricPoint.new(2, 0),
57
+ GeometricPoint.new(5, 1),
58
+ GeometricPoint.new(3, 8),
59
+ GeometricPoint.new(3, 1),
60
+ GeometricPoint.new(1, 4)
61
+ ])
62
+ expect(polygon.bounding_box.leftbottom).to eq(GeometricPoint.new(0, 0))
63
+ expect(polygon.bounding_box.righttop).to eq(GeometricPoint.new(5, 8))
64
+ end
65
+ end
66
+
67
+ describe '#contains?' do
68
+ it 'to be convex' do
69
+ polygon = GeometricPolygon.new([
70
+ GeometricPoint.new(0, 0),
71
+ GeometricPoint.new(1, 0),
72
+ GeometricPoint.new(1, 1),
73
+ GeometricPoint.new(0, 1)
74
+ ])
75
+ inner = GeometricPoint.new(0.5, 0.5)
76
+ outer = GeometricPoint.new(1.5, 1.5)
77
+ on_edge = GeometricPoint.new(0.5, 1)
78
+ at_vertex = GeometricPoint.new(1, 1)
79
+
80
+ expect(polygon.contains?(inner)).to eq(true)
81
+ expect(polygon.contains?(outer)).to eq(false)
82
+ expect(polygon.contains?(on_edge)).to eq(true)
83
+ expect(polygon.contains?(at_vertex)).to eq(true)
84
+ end
85
+
86
+ it 'to be nonconvex' do
87
+ polygon = GeometricPolygon.new([
88
+ GeometricPoint.new(0, 0),
89
+ GeometricPoint.new(0, 6),
90
+ GeometricPoint.new(4, 6),
91
+ GeometricPoint.new(4, 4),
92
+ GeometricPoint.new(2, 4),
93
+ GeometricPoint.new(2, 2),
94
+ GeometricPoint.new(4, 2),
95
+ GeometricPoint.new(4, 0)
96
+ ])
97
+
98
+ inner = GeometricPoint.new(1, 5)
99
+ outer = GeometricPoint.new(7, 5)
100
+
101
+ expect(polygon.contains?(inner)).to eq(true)
102
+ expect(polygon.contains?(outer)).to eq(false)
103
+ end
104
+ end
105
+
106
+ describe '#edges' do
107
+ it 'to be regular' do
108
+ vertices = [
109
+ GeometricPoint.new(0, 0),
110
+ GeometricPoint.new(1, 0),
111
+ GeometricPoint.new(1, 1),
112
+ GeometricPoint.new(0, 1)
113
+ ]
114
+
115
+ polygon = GeometricPolygon.new(vertices)
116
+
117
+ expected_edges = [
118
+ GeometricSegment.new_by_arrays(vertices[0], vertices[1]),
119
+ GeometricSegment.new_by_arrays(vertices[1], vertices[2]),
120
+ GeometricSegment.new_by_arrays(vertices[2], vertices[3]),
121
+ GeometricSegment.new_by_arrays(vertices[3], vertices[0])
122
+ ]
123
+
124
+ expect(polygon.edges).to eq(expected_edges)
125
+ end
126
+
127
+ it 'to be self intersecting' do
128
+ vertices = [
129
+ GeometricPoint.new(0, 0),
130
+ GeometricPoint.new(4, 0),
131
+ GeometricPoint.new(3, 2),
132
+ GeometricPoint.new(1, -2)
133
+ ]
134
+
135
+ polygon = GeometricPolygon.new(vertices)
136
+
137
+ expected_edges = [
138
+ GeometricSegment.new_by_arrays(vertices[0], vertices[1]),
139
+ GeometricSegment.new_by_arrays(vertices[1], vertices[2]),
140
+ GeometricSegment.new_by_arrays(vertices[2], vertices[3]),
141
+ GeometricSegment.new_by_arrays(vertices[3], vertices[0])
142
+ ]
143
+
144
+ expect(polygon.edges).to eq(expected_edges)
145
+ end
146
+ end
147
+
148
+ end