1+ """
2+ Author: Timothy Moore
3+ Created On: 4th September 2017
4+
5+ Contains various approaches to determining if a polygon will
6+ intersect another polygon as one or both polygons go along
7+ a a single direction at a constant speed.
8+
9+ This problem could be thought of as one of extrapolation -
10+ given these initial conditions, extrapolate to determine
11+ if intersections will occur.
12+
13+ .. note::
14+
15+ Touching is not considered intersecting in this module. Touching
16+ is determined using `math.isclose`
17+
18+ """
19+
20+ def calculate_one_moving_and_one_stationary (poly1 , poly1_offset , poly1_velocity , poly2 , poly2_offset ):
21+ """
22+ Determine if the moving polygon will intersect the stationary polygon.
23+
24+ This is the simplest question. Given two polygons, one moving and one not,
25+ determine if the two polygons will ever intersect (assuming they maintain
26+ constant velocity).
27+
28+ :param poly1: the geometry of the polygon that is moving
29+ :type poly1: :class:`pygorithm.geometry.polygon2.Polygon2`
30+ :param poly1_offset: the starting location of the moving polygon
31+ :type poly1_offset: :class:`pygorithm.geometry.vector2.Vector2`
32+ :param poly1_velocity: the velocity of the moving polygon
33+ :type poly1_velocity: :class:`pygorithm.geometry.vector2.Vector2`
34+ :param poly2: the geometry of the stationary polygon
35+ :type poly2: :class:`pygorithm.geometry.polygon2.Polygon2`
36+ :param poly2_offset: the offset of the stationary polygon
37+ :type poly2_offset: :class:`pygorithm.geometry.vector2.Vector2`
38+ :returns: if they will intersect
39+ :rtype: bool
40+ """
41+ pass
42+
43+ def calculate_one_moving_one_stationary_distancelimit (poly1 , poly1_offset , poly1_velocity , poly2 , poly2_offset , max_distance ):
44+ """
45+ Determine if the moving polygon will intersect the stationary polygon
46+ within some distance.
47+
48+ This is a step up, and very similar to the actual problem many any-angle
49+ pathfinding algorithms run into. Given two polygons, 1 moving and 1
50+ stationary, determine if the first polygon will intersect the second
51+ polygon before moving a specified total distance.
52+
53+ :param poly1: the geometry of the polygon that is moving
54+ :type poly1: :class:`pygorithm.geometry.polygon2.Polygon2`
55+ :param poly1_offset: the starting location of the moving polygon
56+ :type poly1_offset: :class:`pygorithm.geometry.vector2.Vector2`
57+ :param poly1_velocity: the velocity of the moving polygon
58+ :type poly1_velocity: :class:`pygorithm.geometry.vector2.Vector2`
59+ :param poly2: the geometry of the stationary polygon
60+ :type poly2: :class:`pygorithm.geometry.polygon2.Polygon2`
61+ :param poly2_offset: the offset of the stationary polygon
62+ :type poly2_offset: :class:`pygorithm.geometry.vector2.Vector2`
63+ :param max_distance: the max distance that poly1 can go
64+ :type max_distance: :class:`numbers.Number`
65+ :returns: if they will intersect
66+ :rtype: bool
67+ """
68+ pass
69+
70+ def calculate_one_moving_one_stationary_along_path (poly1 , poly1_start , poly1_end , poly2 , poly2_offset ):
71+ """
72+ Determine if the moving polygon will intersect the stationary polygon as
73+ it moves from the start to the end.
74+
75+ This is a rewording of :py:func:`.calculate_one_moving_one_stationary_distancelimit`
76+ that is more common. Given two polygons, 1 moving and 1 stationary, where the
77+ moving polygon is going at some speed from one point to another, determine if
78+ the two polygons will intersect.
79+
80+ :param poly1: the geometry of the polygon that is moving
81+ :type poly1: :class:`pygorithm.geometry.polygon2.Polygon2`
82+ :param poly1_start: where the moving polygon begins moving from
83+ :type poly1_start: :class:`pygorithm.geometry.vector2.Vector2`
84+ :param poly1_end: where the moving polygon stops moving
85+ :type poly1_end: :class:`pygorithm.geometry.vector2.Vector2`
86+ :param poly2: the geometry of the stationary polygon
87+ :type poly2: :class:`pygorithm.geometry.polygon2.Polygon2`
88+ :param poly2_offset: the location of the second polygon
89+ :type poly2_offset: :class:`pygorithm.geometry.vector2.Vector2`
90+ :returns: if they will intersect
91+ :rtype: bool
92+ """
93+ pass
94+
95+
96+ def calculate_one_moving_many_stationary (poly1 , poly1_offset , poly1_velocity , other_poly_offset_tuples ):
97+ """
98+ Determine if the moving polygon will intersect anything as it
99+ moves at a constant direction and speed forever.
100+
101+ This is the simplest arrangement of this problem with a collection
102+ of stationary polygons. Given many polygons of which 1 is moving,
103+ determine if the moving polygon intersects the other polygons now or at
104+ some point in the future if it moves at some constant direction and
105+ speed forever.
106+
107+ This does not verify the stationary polygons are not intersecting.
108+
109+ :param poly1: the geometry of the polygon that is moving
110+ :type poly1: :class:`pygorithm.geometry.polygon2.Polygon2`
111+ :param poly1_offset: the starting location of the moving polygon
112+ :type poly1_offset: :class:`pygorithm.geometry.vector2.Vector2`
113+ :param poly1_velocity: the velocity of the moving polygon
114+ :type poly1_velocity: :class:`pygorithm.geometry.vector2.Vector2`
115+ :param other_poly_offset_tuples: list of (polygon, offset) of the stationary polygons
116+ :type other_poly_offset_tuples: list of (:class:`pygorithm.geometry.polygon2.Polygon2`, :class:`pygorithm.geometry.vector2.Vector2`)
117+ :returns: if an intersection will occur
118+ :rtype: bool
119+ """
120+ pass
121+
122+ def calculate_one_moving_many_stationary_distancelimit (poly1 , poly1_offset , poly1_velocity , max_distance , other_poly_offset_tuples ):
123+ """
124+ Determine if the moving polygon will intersect anyything as
125+ it moves in a constant direction and speed for a certain
126+ distance.
127+
128+ This does not verify the stationary polygons are not intersecting.
129+
130+ :param poly1: the geometry of the polygon that is moving
131+ :type poly1: :class:`pygorithm.geometry.polygon2.Polygon2`
132+ :param poly1_offset: the starting location of the moving polygon
133+ :type poly1_offset: :class:`pygorithm.geometry.vector2.Vector2`
134+ :param poly1_velocity: the velocity of the moving polygon
135+ :type poly1_velocity: :class:`pygorithm.geometry.vector2.Vector2`
136+ :param max_distance: the max distance the polygon will go
137+ :type max_distance: :class:`numbers.Number`
138+ :param other_poly_offset_tuples: list of (polygon, offset) of the stationary polygons
139+ :type other_poly_offset_tuples: list of (:class:`pygorithm.geometry.polygon2.Polygon2`, :class:`pygorithm.geometry.vector2.Vector2`)
140+ :returns: if an intersection will occur
141+ :rtype: bool
142+ """
143+ pass
144+
145+ def calculate_one_moving_many_stationary_along_path (poly1 , poly1_start , poly1_end , other_poly_offset_tuples ):
146+ """
147+ Determine if a polygon that moves from one point to another
148+ will intersect anything.
149+
150+ This is the question that the Theta* family of pathfinding
151+ algorithms require. It is simply a rewording of
152+ :py:func:`.calculate_one_moving_many_stationary_distancelimit`
153+
154+ This does not verify the stationary polygons are not intersecting.
155+
156+ :param poly1: the geometry of the polygon that is moving
157+ :type poly1: :class:`pygorithm.geometry.polygon2.Polygon2`
158+ :param poly1_start: where the polygon begins moving from
159+ :type poly1_start: :class:`pygorithm.geometry.vector2.Vector2`
160+ :param poly1_end: where the polygon stops moving at
161+ :type poly1_end: :class:`pygorithm.geometry.vector2.Vector2`
162+ :param other_poly_offset_tuples: list of (polygon, offset) of the stationary polygons
163+ :type other_poly_offset_tuples: list of (:class:`pygorithm.geometry.polygon2.Polygon2`, :class:`pygorithm.geometry.vector2.Vector2`)
164+ :returns: if an intersection will occur
165+ :rtype: bool
166+ """
167+
168+ def calculate_two_moving (poly1 , poly1_offset , poly1_vel , poly2 , poly2_offset , poly2_vel ):
169+ """
170+ Determine if two moving polygons will intersect at some point.
171+
172+ This is the simplest question when there are multiple moving polygons.
173+ Given two polygons moving at a constant velocity and direction forever,
174+ determine if an intersection will occur.
175+
176+ It should be possible for the reader to extrapolate from this function
177+ and the process for stationary polygons to create similar functions to
178+ above where all or some polygons are moving.
179+
180+ :param poly1: the first polygon
181+ :type poly1: :class:`pygorithm.geometry.polygon2.Polygon2`
182+ :param poly1_offset: where the first polygon starts at
183+ :type poly1_offset: :class:`pygorithm.geometry.vector2.Vector2`
184+ :param poly1_vel: the velocity of the first polygon
185+ :type poly1_vel: :class:`pygorithm.geometry.vector2.Vector2`
186+ :param poly2: the second polygon
187+ :type poly2: :class:`pygorithm.geometry.polygon2.Polygon2`
188+ :param poly2_offset: where the second polygon starts at
189+ :type poly2_offset: :class:`pygorithm.geometry.vector2.Vector2`
190+ :param poly2_vel: the velocity of the second polygon
191+ :type poly2_vel: :class:`pygorithm.geometry.vector2.Vector2`
192+ :returns: if an intersectino will occur
193+ :rtype: bool
194+ """
195+ pass
0 commit comments