Asteroids: Difference between revisions
Jump to navigation
Jump to search
imported>Kmk21 No edit summary |
imported>Kmk21 No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
#Ternary search the area of intersection to find maximum. Area is computed by | #Ternary search the area of intersection to find maximum. Area is computed by | ||
##Finding the intersecting polygon | ##Finding the intersecting polygon | ||
###Find all points of either polygon which are contained (inclusively) in the other | ###Find all points of either polygon which are contained (inclusively) in the other or line intersections of the two | ||
####use X-product and iterate over all edges of other polygon | ####use X-product and iterate over all edges of other polygon | ||
####if sign is the same, point is contained | ####if sign is the same, point is contained | ||
Line 25: | Line 25: | ||
[[Category:Kevin's Favorites]] | [[Category:Kevin's Favorites]] | ||
[[Category:Interesting Points]] | [[Category:Interesting Points]] | ||
[[Category:Polygon Containment]] |
Latest revision as of 04:35, 27 August 2016
- fix one of the polygons and adjust the other one's path accordingly (just for simplicity)
- Determine if the polygons ever intersect
- Calculate the path of every vertex on the moving polygon
- if every line passes on the same side of every vertex in the other polygon, they don't intersect
- use X-product to determine which side of line a point is on
- Compute the earliest and latest times any point on the moving polygon intersects a line on fixed polygon.
- Ternary search the area of intersection to find maximum. Area is computed by
- Finding the intersecting polygon
- Find all points of either polygon which are contained (inclusively) in the other or line intersections of the two
- use X-product and iterate over all edges of other polygon
- if sign is the same, point is contained
- Sort points by angle from minimum Y point to get ordering (or just run convex hull on them...we already know they're convex since intersection of two convex things is convex)
- run polygon area formula
- Find all points of either polygon which are contained (inclusively) in the other or line intersections of the two
- Finding the intersecting polygon
Will run faster if you only examine times when one vertex crosses an edge of the other polygon