Skip to content

Commit 1cbec4b

Browse files
committed
Add ay* tsets
* imgs/test_geometry/test_extrapolated_intersection/ ay_test_one_moving_many_stationary.py - 4 tests for one moving many stationary with no intersection * imgs/test_geometry/test_extrapolated_intersection/out/ export ay01, ay02, ay03, and ay04 * tests/test_geometry.py - add ay01, ay02, ay03, ay04 (see imgs)
1 parent c877f6f commit 1cbec4b

6 files changed

+103
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from utils import create_newfig, create_moving_polygon, create_still_polygon, run_or_export
2+
3+
func_code = 'ay'
4+
func_name = 'test_one_moving_many_stationary_no_intr'
5+
6+
def setup_fig01():
7+
fig, ax, renderer = create_newfig('{}01'.format(func_code), xlim=(-1, 12), ylim=(-1, 12))
8+
create_moving_polygon(fig, ax, renderer, ((3, 3, 'botleft'), (4, 3), (4, 4), (3, 4)), (4, 4), 'none')
9+
create_still_polygon(fig, ax, renderer, ((6, 3, 'botleft'), (7, 3), (7, 4), (6, 4)), 'none')
10+
create_still_polygon(fig, ax, renderer, ((3, 6, 'botleft'), (3, 7), (4, 7), (4, 6)), 'none')
11+
create_still_polygon(fig, ax, renderer, ((4, 10), (6, 11), (6, 8), (2, 7)))
12+
13+
return fig, ax, '{}01_{}'.format(func_code, func_name)
14+
15+
def setup_fig02():
16+
fig, ax, renderer = create_newfig('{}02'.format(func_code), xlim=(-3, 9), ylim=(-10, 5))
17+
create_moving_polygon(fig, ax, renderer, ((-1, -9.5), (-1, -5.5), (3, -5.5), (4, -7.5)), (3, 6))
18+
create_still_polygon(fig, ax, renderer, ((6, -6), (8, -7), (7, -9)))
19+
create_still_polygon(fig, ax, renderer, ((0, 2), (2, 3), (1, 1)))
20+
create_still_polygon(fig, ax, renderer, ((-2, -2, 'botleft'), (-2, -1), (-1, -1), (-1, -2)), 'none')
21+
create_still_polygon(fig, ax, renderer, ((8, -4, 'botleft'), (8, -3), (7, -3), (7, -4)), 'none')
22+
23+
return fig, ax, '{}02_{}'.format(func_code, func_name)
24+
25+
def setup_fig03():
26+
fig, ax, renderer = create_newfig('{}03'.format(func_code), xlim=(-1, 21), ylim=(-1, 15))
27+
create_moving_polygon(fig, ax, renderer, ((18.5, 3), (17.5, 3), (17.5, 5), (19.5, 5)), (-3, 9))
28+
create_still_polygon(fig, ax, renderer, ((18, 13), (20, 14), (18.5, 11)))
29+
create_still_polygon(fig, ax, renderer, ((5, 5), (6, 2), (3, 3), (2, 4)))
30+
31+
return fig, ax, '{}03_{}'.format(func_code, func_name)
32+
33+
def setup_fig04():
34+
fig, ax, renderer = create_newfig('{}04'.format(func_code), xlim=(-9, 7), ylim=(-4, 6))
35+
create_moving_polygon(fig, ax, renderer, ((-6, 2), (-6, 1), (-8, 0), (-8, 2)), (5, 0))
36+
create_still_polygon(fig, ax, renderer, ((-7, 3, 'botleft'), (-7, 4), (-6, 4), (-6, 3)), 'none')
37+
create_still_polygon(fig, ax, renderer, ((-6, 3, 'botleft'), (-6, 4), (-5, 4), (-5, 3)), 'none')
38+
create_still_polygon(fig, ax, renderer, ((-5, 3, 'botleft'), (-5, 4), (-4, 4), (-4, 3)), 'none')
39+
create_still_polygon(fig, ax, renderer, ((-4, 3, 'botleft'), (-4, 4), (-3, 4), (-3, 3)), 'none')
40+
41+
42+
return fig, ax, '{}04_{}'.format(func_code, func_name)
43+
44+
run_or_export(setup_fig01, setup_fig02, setup_fig03, setup_fig04)
Loading
Loading
Loading
Loading

Diff for: tests/test_geometry.py

+59-1
Original file line numberDiff line numberDiff line change
@@ -2072,8 +2072,66 @@ def test_one_moving_one_stationary_along_path_intr_after_end(self):
20722072
self.assertFalse(intr, msg=msg)
20732073

20742074
# calculate_one_moving_many_stationary
2075+
def _calc_one_moving_many_stat_fuzzer(self, poly1tup, poly1vec, other_poly_tups_arr):
2076+
fn = self.extr_intr.calculate_one_moving_many_stationary
2077+
2078+
poly1 = polygon2.Polygon2(list(vector2.Vector2(p) for p in poly1tup))
2079+
vec1 = vector2.Vector2(poly1vec)
2080+
other_polys_arr = list(polygon2.Polygon2(list(vector2.Vector2(p) for p in poly)) for poly in other_poly_tups_arr)
2081+
2082+
offset1 = vector2.Vector2(random.uniform(-1000, 1000), random.uniform(-1000, 1000))
2083+
other_offsets = list(random.uniform(-1000, 1000) for poly in other_polys_arr)
2084+
2085+
newpoly1 = polygon2.Polygon2(list(p + offset1 for p in poly1.points))
2086+
other_polys_offsets_comb = list((polygon2.Polygon2(list(p + other_offsets[i] for p in other_polys_arr[i].points)), other_offsets[i]) for i in range(len(other_offsets)))
2087+
2088+
msg = "poly1={}\nvec1={}\noffset1={}\n\nOTHER POLYGONS:\n\n"
2089+
2090+
for ind, tup in enumerate(other_polys_offsets_comb):
2091+
poly = tup[0]
2092+
offset = tup[1]
2093+
2094+
msg = msg + "poly{}={}\noffset{}={}".format(ind, poly, ind, offset)
2095+
2096+
result = fn(poly1, offset1, vec1, other_polys_offsets_comb)
2097+
return result, msg
2098+
20752099
def test_one_moving_many_stationary_no_intr(self):
2076-
pass
2100+
fn = self._calc_one_moving_many_stat_fuzzer
2101+
2102+
# ay01
2103+
intr, msg = fn(((3, 3), (4, 3), (4, 4), (3, 4)), (1, 1), [
2104+
((6, 3), (7, 3), (7, 4), (6, 4)),
2105+
((3, 6), (3, 7), (4, 7), (4, 6)),
2106+
((4, 10), (6, 11), (6, 8), (2, 7))
2107+
])
2108+
self.assertFalse(intr, msg=msg)
2109+
2110+
# ay02
2111+
intr, msg = fn(((-1, -9.5), (-1, -5.5), (3, -5.5), (4, -7.5)), (1, 2), [
2112+
((6, -6), (8, -7), (7, -9)),
2113+
((0, 2), (2, 3), (1, 1)),
2114+
((-2, -2), (-2, -1), (-1, -1), (-1, -2)),
2115+
((8, -4), (8, -3), (7, -3), (7, -4))
2116+
])
2117+
self.assertFalse(intr, msg=msg)
2118+
2119+
# ay03
2120+
intr, msg = fn(((18.5, 3), (17.5, 3), (17.5, 5), (19.5, 5)), (-1, 3), [
2121+
((18, 13), (20, 14), (18.5, 11)),
2122+
((5, 5), (6, 2), (3, 3), (2, 4))
2123+
])
2124+
self.assertFalse(intr, msg=msg)
2125+
2126+
# ay04
2127+
intr, msg = fn(((-6, 2), (-6, 1), (-8, 0), (-8, 2)), (10, 0), [
2128+
((-7, 3), (-7, 4), (-6, 4), (-6, 3)),
2129+
((-6, 3), (-6, 4), (-5, 4), (-5, 3)),
2130+
((-5, 3), (-5, 4), (-4, 4), (-4, 3)),
2131+
((-4, 3), (-4, 4), (-3, 4), (-3, 3))
2132+
])
2133+
self.assertFalse(intr, msg=msg)
2134+
20772135
def test_one_moving_many_stationary_touching(self):
20782136
pass
20792137
def test_one_moving_many_stationary_intr_at_start(self):

0 commit comments

Comments
 (0)